Workbooks.open
Hello all,
I have tried numerous ways to modify the responses to "Openening an Excel file from within project" to open an existing Excel workbook and also select and activate a minimized workbook but have totally struck out, Can anyone give me some guidance? Also, where should I be looking for samples that answer such basic questions?
Thanks very much.
Noel Rietman
Thank you for your reply. I added the Excel 11.0 object Library however I get the same errors.
Dim w2 As Excel.Workbook = XL.Workbooks.Open("C:\MyXL.xls") Excel.Workbook not declared
Is there something I need to declare at the top of my code? Sorry if I am a bit new but am trying to move from VBA to .net.
Thanks for any help
Tom Hallmark
This is the code that MSDN says will open a workbook. It Does not work.
All I get with this is "Type Excel.Workbook is Not Defined" How do I define it?
Thanks for any help.
Tom Hallmark
The Workbooks collection in Microsoft Office Excel 2003 makes it possible to work with all the open workbooks, create a new workbook, and import data into a new workbook.
To open an existing workbook
- Use the Open method of the Workbooks collection, passing in the path to the workbook:
' Visual BasicDim wb As Excel.Workbook = _
ThisApplication.Workbooks.Open("C:\YourPath\YourWorkbook.xls")
The Workbooks collection in Microsoft Office Excel 2003 makes it possible to work with all the open workbooks, create a new workbook, and import data into a new workbook.
To open an existing workbook
I could only get the import declaration to work by enclosing each line in <% %> delimiters as below
<%
@ Import Namespace="System"%>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.sqlClient"%>