Open file with open dialog box
Hi James
I have been trying this little script. It runs through fine but then wishes
to restart from the beginning but then end once it has opened the file.
This is what I have. Except for my very long script.
Sub ConsolFileMulti()
Application.Workbooks.Open (GetFileNameMulti)
End Sub
Function GetFileNameMulti()
'Get a FileName (may change current drive/directory.)
Filename = Application.GetOpenFilename
'Get the current directory and drive
TempDir = CurDir()
'Switch back to original drive
ChDrive Mid(TempDir, 1, 1)
'Switch back to the original directory
ChDir TempDir
'Return the filename
GetFileNameMulti = Filename
If GetFileNameMulti = False Then
MsgBox "No File was selected, the macro will now end"
End
Else
Application.Workbooks.Open (GetFileNameMulti)
End If
' the start of a really long script
€˜ end of the really long script
End Function
What am I doing to cause the loop.
TIA Regards Noel
" wrote:
Hi Jafery,
Somewhere with in either your function/module you just need to say if
Getfilename = false then...
With in your module you could write:
If Getfilename = False then
Msgbox "No File was selected, the macro will now end"
End
Else
Application.Workbooks.Open (GetFileName)
End if
Regards,
James
|