subscript out of range

  • Thread starter Sri via OfficeKB.com
  • Start date
S

Sri via OfficeKB.com

Hello,

While I execute the following code, I get "subscript out of range" error at
the last line.
The file "Report_2009-04-16.xls" exists in the location mentioned in vPath.
Could any body help me out here please ...

Dim srcDBName As String
Dim xlw_source As Excel.Workbook

inpDate = "2009-04-16"
vPath = ThisWorkbook.Path
srcDBName = vPath & "\" & "Report_" & inpDate & ".xls"
Set xlw_source = Excel.Workbooks(srcDBName)
 
G

Gary''s Student

Need to make sure the instance exists and is properly referenced:

Sub dural()
Dim xlw_source As Workbook
Dim srcDBName As String
srcDBName = "C:\test\beta.xls"
shortName = "beta.xls"
Workbooks.Open Filename:=srcDBName
Set xlw_source = Excel.Workbooks(shortName)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top