|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Accessing existing Excel Workbook from complete pathI am trying to open a Excel Workbook to check data in worksheets. The ONLY info I have about the EXCEL file is its entire path. I tried to do the following, but an exception occurs: Dim _objXLApp As Excel.ApplicationClass Dim _objXLFile As Excel.Workbook Dim _objWorkSheets As Excel.Worksheets Dim _objXLSheet As Excel.Worksheet Dim _objRange As Excel.Range Dim _strPath As String _strPath = "C:\LOCALDATA\FCP_93.xls" _objXLApp = New Excel.ApplicationClass _objXLApp.Visible = False Try _objXLFile = _objXLApp.Workbooks(_strPath) 'EXCEPTION HERE: "Invalid Index" _objWorkSheets = _objXLFile.Worksheets() ' code continues here Catch ex As Exception Show(ex.Message) End Try Any idea? Thanks. L. On 2 May 2006 04:47:35 -0700, "Lucile" <lucile.di***@dexia-am.com> wrote: ¤ Hi all,¤ ¤ I am trying to open a Excel Workbook to check data in worksheets. The ¤ ONLY info I have about the EXCEL file is its entire path. I tried to do ¤ the following, but an exception occurs: ¤ ¤ ¤ Dim _objXLApp As Excel.ApplicationClass ¤ Dim _objXLFile As Excel.Workbook ¤ Dim _objWorkSheets As Excel.Worksheets ¤ Dim _objXLSheet As Excel.Worksheet ¤ Dim _objRange As Excel.Range ¤ Dim _strPath As String ¤ ¤ _strPath = "C:\LOCALDATA\FCP_93.xls" ¤ _objXLApp = New Excel.ApplicationClass ¤ _objXLApp.Visible = False ¤ Try ¤ _objXLFile = _objXLApp.Workbooks(_strPath) 'EXCEPTION HERE: ¤ "Invalid Index" ¤ _objWorkSheets = _objXLFile.Worksheets() ¤ ¤ ' code continues here ¤ Catch ex As Exception ¤ Show(ex.Message) ¤ End Try ¤ I believe you're looking for the Open method of the Workbooks collection object. Paul ~~~~ Microsoft MVP (Visual Basic)
vb.net, so slow !!!???
How about: How do I attach a file to an email w/MailTo: ? Collections strong reference between objects in different assemblies General Question About Web Apps, VB/ASP? Appending two data tables Creating Worksheets from Existing Excel Instances in VB.NET? besides mailto: another way to launch mail program and populate fields? Application Error: CiceroUIWndFrame How to control Bluetooth? |
|||||||||||||||||||||||