JaFF
05-11-2011, 01:53 PM
Hello VBA users,
I'm relatively new to VBA although I know basic programming. My ultimate goal is to open a workbook the name of which is specified in a cell in a sheet in the workbook that is already open. As I understand the code for that would be something like this:
Dim file As String
file = Sheets("History").Cells(2, 1)
Workbooks.Open Filename = "C:\" & file
However, this gives me a run-time error 1004. The error message box is not helpful at all: instead of a basic description I get a lot of "?" marks with "False.xlsx" between them (so it converted whatever characters there were into ? but left the False.xlsx and the punctuation marks untouched). I know that the file exists and the name is correct - I've manually created .xls and .xlsx files and tried to read those which resulted in the same error. I also know that the sheets I created were not protected.
I'm sorry I'm not being very helpful, but are there any common mistakes that can lead to this?
Thanks!
I'm relatively new to VBA although I know basic programming. My ultimate goal is to open a workbook the name of which is specified in a cell in a sheet in the workbook that is already open. As I understand the code for that would be something like this:
Dim file As String
file = Sheets("History").Cells(2, 1)
Workbooks.Open Filename = "C:\" & file
However, this gives me a run-time error 1004. The error message box is not helpful at all: instead of a basic description I get a lot of "?" marks with "False.xlsx" between them (so it converted whatever characters there were into ? but left the False.xlsx and the punctuation marks untouched). I know that the file exists and the name is correct - I've manually created .xls and .xlsx files and tried to read those which resulted in the same error. I also know that the sheets I created were not protected.
I'm sorry I'm not being very helpful, but are there any common mistakes that can lead to this?
Thanks!