Hello,
I wonder if someone can tell me how to do something in FileDialog?
I previously had many private functions using FileDialog, but have now decided to put the basic code in a public function and call it from the private ones.
This works fine, but if, when FileDialog is open, the user presses Cancel, Im having trouble.
My code is below, how do I set the code to look for Cancel? Can a procedure be ended in the public function without it being returned to the private one (IE Exit Sub seems to end the public, but sends the user back into Private.
Thanks
I wonder if someone can tell me how to do something in FileDialog?
I previously had many private functions using FileDialog, but have now decided to put the basic code in a public function and call it from the private ones.
This works fine, but if, when FileDialog is open, the user presses Cancel, Im having trouble.
My code is below, how do I set the code to look for Cancel? Can a procedure be ended in the public function without it being returned to the private one (IE Exit Sub seems to end the public, but sends the user back into Private.
Thanks
Code:
[SIZE=3][COLOR=#000080][FONT=Arial]Public Sub Export()[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set FDialog = Application.FileDialog(msoFileDialogSaveAs)[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]With FDialog[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial].AllowMultiSelect = False[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial].InitialFileName = “MyFile”[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial].Title = "Please select a save location"[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]If .Show = True Then[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]For Each varFile In .SelectedItems[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]DestFile = .SelectedItems(1) [/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Next[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]End If [/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]End With[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]End Sub[/FONT][/COLOR][/SIZE]