Connecting Tech Pros Worldwide Forums | Help | Site Map

Access to Excel

Steve Spittell
Guest
 
Posts: n/a
#1: Nov 13 '05

Need some assistance, I am trying to take recordset from Access that
contains Names;

Name1
Name2
Name3
Name4, etc

Open up an Excel Workbook and Create New Worksheets based on the names
in the Recordset.

*** Sent via Developersdex http://www.developersdex.com ***

David Lloyd
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Access to Excel


Steve:

One approach is to use Automation from Access to open Excel and create the
new worksheets.

For example:

Dim i as Integer
Dim xlapp as Excel.Application
Dim wkb as Workbook
Dim wks as Worksheet

Set xlapp = CreateObject("Excel.Application")

Set wkb = xlapp.Workbooks.Add()

'rs is your recordset
For i = 0 to rs.Fields.Count - 1
Set wks = wkb.WorkSheets.Add()
wks.Name = rs.Fields(i).Name
Next i

I have not tested this, but something similar should work. You can decide
whether to keep the default worksheets (Sheet1, ...) in the workbook. You
will also need a reference to the Excel Object Library.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


"Steve Spittell" <sspittell@yahoo.com> wrote in message
news:EUSie.30$LL1.4000@news.uswest.net...

Need some assistance, I am trying to take recordset from Access that
contains Names;

Name1
Name2
Name3
Name4, etc

Open up an Excel Workbook and Create New Worksheets based on the names
in the Recordset.

*** Sent via Developersdex http://www.developersdex.com ***


Closed Thread