I'm creating an output file using FileSystemObject in Excel VBA, and I want to enable the user to choose the location where to save his output using a FileDialog box.
Here is a s snippet of my code,
Dim objFSO As FileSystemObject
Dim tsStream As TextStream
Dim strFilePath as String
Dim FD as FileDialog
Set FD = Application.FileDialog(msoFileDialogSaveAs)
With FD
.AllowMultiSelect = False
If .Show = -1 Then
For Each i in .SelectedItems
strFilePath = i
Next i
Else
End If
End With
Set FD = Nothing
Set objFSO = New FileSystemObject
Set tsStream = objFSO.CreateTextFile(strFilePath &".txt", True)
The problem is the code's "Save as type:" is Excel file types.
Can anybody help me?