M
Maury Markowitz
One of my functions exports a text file to disk. Right now it does so to a
filename based on the date and time, which is OK. However I'd really like to
add a Save As dialog to allow the user to pick the filename, or let them
overwrite existing ones.
There's some sample code in VBA help, but it doesn't work. It goes like this
(sorry, commented it out in my code)...
' Set fileDialog = Application.fileDialog(msoFileDialogSaveAs)
' With fileDialog
' .AllowMultiSelect = False
'
' ' show the dialg and then see what button they pressed
' If .Show = -1 Then
'
' 'Step through each string in the FileDialogSelectedItems
collection
' For Each vrtSelectedItem In .SelectedItems
'
' 'vrtSelectedItem is a String that contains the path of each
selected item.
' 'You can use any file I/O functions that you want to work
with this path.
' 'This example simply displays the path in a message box.
' MsgBox "Selected item's path: " & vrtSelectedItem
'
' Next vrtSelectedItem
' Else
' ' they pressed Cancel
' Exit Sub
' End If
' End With
So what happens? I get a "fileDialog of object _Application failed".
Any ideas?
filename based on the date and time, which is OK. However I'd really like to
add a Save As dialog to allow the user to pick the filename, or let them
overwrite existing ones.
There's some sample code in VBA help, but it doesn't work. It goes like this
(sorry, commented it out in my code)...
' Set fileDialog = Application.fileDialog(msoFileDialogSaveAs)
' With fileDialog
' .AllowMultiSelect = False
'
' ' show the dialg and then see what button they pressed
' If .Show = -1 Then
'
' 'Step through each string in the FileDialogSelectedItems
collection
' For Each vrtSelectedItem In .SelectedItems
'
' 'vrtSelectedItem is a String that contains the path of each
selected item.
' 'You can use any file I/O functions that you want to work
with this path.
' 'This example simply displays the path in a message box.
' MsgBox "Selected item's path: " & vrtSelectedItem
'
' Next vrtSelectedItem
' Else
' ' they pressed Cancel
' Exit Sub
' End If
' End With
So what happens? I get a "fileDialog of object _Application failed".
Any ideas?