Click here to Skip to main content
16,016,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Create a new TextFile With command button in excel.
I have added this code
Public Sub PopulateTextFile()
    Dim fso As New FileSystemObject
    Dim oFile As TextStream
    
    If (Not fso.FileExists("C:\Test.txt")) Then
        Set oFile = fso.CreateTextFile("C:\Test.txt", False)
    End If
    
    oFile.WriteLine "Test"
    
    oFile.Close
    
    Set oFile = Nothing
    Set fso = Nothing 
   
End Sub

But It Is Showing Error:User Defined Type Not Defined at fso
Please give any suggestions....
Posted
Updated 19-Jun-11 22:13pm
v2

Sorry for troubling you people....
I got solution for this,as i have to add reference as
MicrosoftScriptingRuntime
 
Share this answer
 
Comments
Tarun.K.S 20-Jun-11 4:15am    
Great that you found the answer. 5+
Your code is not able to detect FileSystemObject. Make sure this scripting component is correctly registered on your PC.
Also, in VBE. goto Tools -> References and check Microsoft Scripting Runtime is added.
 
Share this answer
 
Comments
Tarun.K.S 20-Jun-11 4:15am    
Exactly. 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900