tranchemontaigne
Registered User.
- Local time
- Today, 14:09
- Joined
- Aug 12, 2008
- Messages
- 203
OBJECTIVE:
I am trying to figure out how to create text files using VBA.
PROBLEM:
Unfortunately none of my books address FileSystemObjects. Code samples I have seen on the net don't work for me and I wonder if I need a special library reference to make this work.
FUNCTION OBJECTIVE:
Function should be able to receive a string variable and create a new text file that contains nothing other than the string variable's value
Here's a snippet of my broken code
Cloudy Trichomes
I am trying to figure out how to create text files using VBA.
PROBLEM:
Unfortunately none of my books address FileSystemObjects. Code samples I have seen on the net don't work for me and I wonder if I need a special library reference to make this work.
FUNCTION OBJECTIVE:
Function should be able to receive a string variable and create a new text file that contains nothing other than the string variable's value
Here's a snippet of my broken code
________Public Function fnTest(strPayload as string)
'//////////////////////////////////////////////////////////////////
'// Requirements:
'// Microsoft Visual Basic for Applications
'// Microsoft Access 9.0 Object Library
'// Microsoft Scripting Runtime (scrrun.dll)
'//
'//////////////////////////////////////////////////////////////////
Dim fso As New FileSystemObject
Dim a As FileSystemObject
strPayload = "This is a test
Set fso = CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile("C:\My Documents\TestFile.txt", True)
a.WriteLine (strPayload )
a.Close
MsgBox "done"
End Function
Cloudy Trichomes
Last edited: