Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Create Excel Worksheets Using ADO

Status
Not open for further replies.

chamira

Programmer
Apr 17, 2001
6
US
Does anyone know how to set the number of worksheets in an Excel spreadsheet after connecting to it using ADO. This is how I've setup the connection:

Dim xlConn As New ADODB.Connection
xlConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\anyFile.xls;Extended Properties=Excel 8.0;"
...
xlConn.Close
Set xlConn = Nothing

I know it is possible to set the number of worksheets if you create an Excel object (as shown below), but I'd like to know if its possible to do it with an ADO connection. Thanks.

Dim xlApp As Excel.Application
Dim wkBook As Excel.Workbook
Set xlApp = New Excel.Application
Set wkBook = xlApp.Workbooks.Add
xlApp.SheetsInNewWorkbook = 10
...
wkBook.Close SaveChanges:=True
xlApp.Quit
Set wkSheet = Nothing
Set wkBook = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top