Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Exporting Access data to different worksheets on the same workbook


Hi there,

I have three Access 97 tables that I am trying to export Excel fro
VBA. The problem is I would like all three to be on the same workboo
rather than on different workbooks (i.e., having one workboo
containing three tabs each for a differnt table data)

The code I am using right now which creates three different workbook
are as below:

DoCmd.OutputTo acQuery, "Table1", acFormatXLS, "C:\Data\Table1.xls"
True

DoCmd.OutputTo acQuery, "Table2", acFormatXLS, "C:\Data\Table2.xls"
True

DoCmd.OutputTo acQuery, "Table3", acFormatXLS, "C:\Data\Table3.xls"
True

I would very much appreciate all suggestions and help!!!

Thanks,
chill

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Exporting Access data to different worksheets on the same workbook

Access 2002

Add a new module. Under Tools/references in the IDE that
should open automatically, set a reference to the
Microsoft Excel 10 Object Library then add this code


Function Save_to_Excel()
Dim XLapp As Excel.Application
Dim xlWB As Excel.Workbook
Dim xlWS As Excel.Worksheet

Set XLapp = New Excel.Application

Set xlWB = XLapp.Workbooks.Open("C:\Data\Temp.xls")

Set xlWS = xlWB.Worksheets("Sheet1")

Dim rst As Recordset

Set XLapp = New Excel.Application

Set rst = CurrentDb.OpenRecordset("table1")

xlWS.Range("A6500").End(xlUp).Offset(1,
0).CopyFromRecordset rst

rst.Close

Set rst = CurrentDb.OpenRecordset("table2")

xlWS.Range("A6500").End(xlUp).Offset(1,
0).CopyFromRecordset rst

xlWB.Close True

Set xlWS = Nothing
Set xlWB = Nothing

XLapp.Quit

Set XLapp = Nothing

End Function

code tested ok

This will get you started

Patrick Molloy
Microsoft Excel MVP


-----Original Message-----

Hi there,

I have three Access 97 tables that I am trying to export

Excel from
VBA. The problem is I would like all three to be on the

same workbook
rather than on different workbooks (i.e., having one

workbook
containing three tabs each for a differnt table data)

The code I am using right now which creates three

different workbooks
are as below:

DoCmd.OutputTo acQuery, "Table1",

acFormatXLS, "C:\Data\Table1.xls",
True

DoCmd.OutputTo acQuery, "Table2",

acFormatXLS, "C:\Data\Table2.xls",
True

DoCmd.OutputTo acQuery, "Table3",

acFormatXLS, "C:\Data\Table3.xls",
True

I would very much appreciate all suggestions and help!!!

Thanks,
chill.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by

step guide to creating financial statements
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting Current Access data into Template? TKM Excel Worksheet Functions 1 November 14th 06 07:28 PM
exporting data from access to excel [email protected] Excel Discussion (Misc queries) 1 April 11th 06 10:17 AM
Exporting data from access to excel vinayak Excel Worksheet Functions 0 April 11th 06 08:20 AM
Exporting data to access Carl Meade Excel Programming 3 November 18th 03 04:09 PM
Help exporting worksheets/data to a workbook. Tbird Excel Programming 2 October 22nd 03 07:18 PM


All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"