I am accessing an MS Excel file and wish to position on a specific worksheet using a variable.
this is my code:
***********************************
Dim ExcelApp As Excel.Application
Dim ExcelWorkbook As Excel.Workbook
Dim ExcelSheet As Excel.Worksheet
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelWorkbook = ExcelApp.Workbooks.Open(FN)
Set ExcelSheet = ExcelWorkbook.Worksheets(WS)
********************************
FN contains the pathname and filename of the excel file
WS contains the name of the worksheet
I can't seem to access the worksheet in this manner. I get a subscript out of range error.
Can anybody help me please?
this is my code:
***********************************
Dim ExcelApp As Excel.Application
Dim ExcelWorkbook As Excel.Workbook
Dim ExcelSheet As Excel.Worksheet
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelWorkbook = ExcelApp.Workbooks.Open(FN)
Set ExcelSheet = ExcelWorkbook.Worksheets(WS)
********************************
FN contains the pathname and filename of the excel file
WS contains the name of the worksheet
I can't seem to access the worksheet in this manner. I get a subscript out of range error.
Can anybody help me please?