error 9 - simple code
Can you post your code here so I can have a look?
"PBcorn" wrote:
Excel 2002 SP3
cstr generates the same error, wb.fullname.tostring generates "invalid
qualifier".
Please advise.
"Sam Wilson" wrote:
What version of excel are you using? It mustn't be treating wb.fullname as a
string...
try cstr(wb.fullname) instead? or wb.fullname.tostring
"PBcorn" wrote:
This generates a type mismatch error 13. please advise.
"Sam Wilson" wrote:
It's because the workbooks collection contains only open workbooks.
You can try the following, which checks all the open workbooks against the
path you've specified:
Sub test()
Dim path As String
path = "C:\blah.xls"
Dim wb As Workbook
For Each wb In Workbooks
If wb.FullName = path Then Exit Sub
Next wb
Workbooks.Open Filename:=path
End Sub
You should be able to
"PBcorn" wrote:
to open a workbook if it is not already open:
dim path as string
path = " letter:\...\\workbook.xls"
If Workbooks(path).IsOpen = False Then
workbooks.open filename:=path
Gives subscript out of range. The solutions i found by searching the forum
are a bit long-winded - why doesn't the above work?
|