-
Solved: Create User Defined Text File
[VBA]Sub CreateAfile()
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile("c:\testfile.txt", True)
f.WriteLine ("This is a test.")
f.Close
End Sub[/VBA]
I can use VBA to Create a text file via the manner above. But the problem is that the programmer dictates the location and file name in the code. Is there a way to have the user define the folder and file name with a dialog box? If so, how?
-
Use the GetSaveAsFilename dialog.
[vba]Sub CreateAfile()
Dim vntSaveName as Variant
vntSaveName = application.GetSaveAsFilename
if vntSaveName = "False" then exit sub
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile(vntSaveName, True)
f.WriteLine ("This is a test.")
f.Close
End Sub [/vba]
-
That worked nicely.
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules