I created the following function which was working fine for the past couple days while testing, until now.
I'm getting an error on the line: Workbooks.Open FileName:=FileToOpen
Error Msg: Method 'Range' of object '_Global' failed
FileToOpen variable has the following value which is 155 characters in length:
C:\Documents and Settings\BN0061\My Documents\EXCEL VBA\Family Care\Winder Model\enhancement08\Family Care Converting Winding Model v8 - test archiving.xls
Any ideas of why this would cause an error? The only thing different in the test is the filename. I had tested a file earlier in the same location. Interestingly, the file does open when this function is called, but still throws the error.
I'm using Excel 2003, but will test later in Excel 2007.
thanks for any help.
I'm getting an error on the line: Workbooks.Open FileName:=FileToOpen
Error Msg: Method 'Range' of object '_Global' failed
Code:
Function Get_FileToOpen()
FileToOpen = Application.GetOpenFilename _
(Title:="Please choose a file to import", _
FileFilter:="Excel Files *.xls (*.xls),")
''
If FileToOpen = False Then
MsgBox "No file specified.", vbExclamation, "Please Try Again."
Get_FileToOpen = ""
Else
Debug.Print FileToOpen
Workbooks.Open FileName:=FileToOpen
Get_FileToOpen = FileToOpen
End If
End Function
FileToOpen variable has the following value which is 155 characters in length:
C:\Documents and Settings\BN0061\My Documents\EXCEL VBA\Family Care\Winder Model\enhancement08\Family Care Converting Winding Model v8 - test archiving.xls
Any ideas of why this would cause an error? The only thing different in the test is the filename. I had tested a file earlier in the same location. Interestingly, the file does open when this function is called, but still throws the error.
I'm using Excel 2003, but will test later in Excel 2007.
thanks for any help.
Last edited: