By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,557 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

Access to Excel

P: n/a

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 ***
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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" <ss*******@yahoo.com> wrote in message
news:EU***************@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 ***
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.