RoundRocket
New Member
- Joined
- Nov 28, 2013
- Messages
- 24
Hi,
Below is the starting code of a macro in excel 2007 which does a find and replace for a word document. It is currently set up to allow the user to navigate to a file, which works fine...but i would like to be able to give the user the option to either navigate to, or, just use the active document that is open at the time the macro is run. I am not sure how to amend this code, but i'm guessing it would involve a msgbox with a choice, so that the user can click 'yes' to navigate to a file as it is currently set to do, or 'no' to use current open document. Any help /suggestions you could give would be a fantastic help. Thank you, Alex
Sub Button5_Click()
Dim file
file = Application.GetOpenFilename(Title:="Please choose a file to import")
If file = "" Or file = False Then
MsgBox "You must select a file, please try again"
Exit Sub
End If
Below is the starting code of a macro in excel 2007 which does a find and replace for a word document. It is currently set up to allow the user to navigate to a file, which works fine...but i would like to be able to give the user the option to either navigate to, or, just use the active document that is open at the time the macro is run. I am not sure how to amend this code, but i'm guessing it would involve a msgbox with a choice, so that the user can click 'yes' to navigate to a file as it is currently set to do, or 'no' to use current open document. Any help /suggestions you could give would be a fantastic help. Thank you, Alex
Sub Button5_Click()
Dim file
file = Application.GetOpenFilename(Title:="Please choose a file to import")
If file = "" Or file = False Then
MsgBox "You must select a file, please try again"
Exit Sub
End If