I have a VBA program that generates output text files from data on a worksheet. The output text files are generated correctly however I cannot seem to get the output text files to write to a directory of my chosing. Here is the code for selecting the directory
Private Sub SetDirectory_Click()
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Select a location for ANSYS Macros and Data Files."
.Show
If .SelectedItems.Count = 0 Then
MsgBox "Canceled"
Else
MsgBox .SelectedItems(1)
End If
End With
End Sub
The message box comes back with the correct directory chosen, but the files all write to the User Documents directory. In the code where the output files are created I have the follwoing code:
intFH = FreeFile()
Filename = Application.DefaultFilePath & "\Empty.txt"
Open Filename For Output As intFH
Is there a setting in Windows 7 or Excel that I am missing?? Any ideas?
Thanks in advance for help with this.
Private Sub SetDirectory_Click()
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Select a location for ANSYS Macros and Data Files."
.Show
If .SelectedItems.Count = 0 Then
MsgBox "Canceled"
Else
MsgBox .SelectedItems(1)
End If
End With
End Sub
The message box comes back with the correct directory chosen, but the files all write to the User Documents directory. In the code where the output files are created I have the follwoing code:
intFH = FreeFile()
Filename = Application.DefaultFilePath & "\Empty.txt"
Open Filename For Output As intFH
Is there a setting in Windows 7 or Excel that I am missing?? Any ideas?
Thanks in advance for help with this.