HOW TO SAVE 3 TABLES (AS A SHEET NAMES) IN ONE 1 EXCEL FILE IN ACCESS

A

arni

Please advise how to output different tables in one excel
file? The output should be saves in one excel file but
will have different sheet names based on the table names.
For example, the database have A, B, and C tables. I
would like to saved these into 1 excel file having 3
sheets namely A, B and C.

Please advise how to do this in access?

Help is very much appreciated.

arni :]
 
M

MacDermott

This can be coded using Automation of Excel and DAO's RecordsetCopy command.

HTH
- Turtle
 
A

arni

Could I have a sample code of doing this in access/excel?

tanx,
arni
-----Original Message-----
This can be coded using Automation of Excel and DAO's RecordsetCopy command.

HTH
- Turtle

Please advise how to output different tables in one excel
file? The output should be saves in one excel file but
will have different sheet names based on the table names.
For example, the database have A, B, and C tables. I
would like to saved these into 1 excel file having 3
sheets namely A, B and C.

Please advise how to do this in access?

Help is very much appreciated.

arni :]


.
 
M

MacDermott

AIR CODE:

Set a reference to your Excel library.

Dim XL as New Excel.Application
Dim RST as DAO.Recordset
Set RST=CurrentDB.OpenRecordset("A")
XL.Documents.Add "C:\ExcelFiles\ExcelCombo.xls"
XL.Sheets("Sheet1").Name="A"
XL.Sheets("Sheet2").Name="B"
XL.Sheets("Sheet3").Name="C"
XL.Sheets("A").Range("A1").CopyFromRecordset RST
rst.close
Set RST=CurrentDB.OpenRecordset("B")
XL.Sheets("B").Range("A1").CopyFromRecordset RST
rst.close
Set RST=CurrentDB.OpenRecordset("C")
XL.Sheets("C").Range("A1").CopyFromRecordset RST
rst.close
XL.ActiveWorkbook.Save
XL.ActiveWorkbook.Close
XL.Quit
Set XL=Nothing

HTH
- Turtle


arni said:
Could I have a sample code of doing this in access/excel?

tanx,
arni
-----Original Message-----
This can be coded using Automation of Excel and DAO's RecordsetCopy command.

HTH
- Turtle

Please advise how to output different tables in one excel
file? The output should be saves in one excel file but
will have different sheet names based on the table names.
For example, the database have A, B, and C tables. I
would like to saved these into 1 excel file having 3
sheets namely A, B and C.

Please advise how to do this in access?

Help is very much appreciated.

arni :]


.
 
A

arni

MacDermott,

many thanks,

:]
-----Original Message-----
AIR CODE:

Set a reference to your Excel library.

Dim XL as New Excel.Application
Dim RST as DAO.Recordset
Set RST=CurrentDB.OpenRecordset("A")
XL.Documents.Add "C:\ExcelFiles\ExcelCombo.xls"
XL.Sheets("Sheet1").Name="A"
XL.Sheets("Sheet2").Name="B"
XL.Sheets("Sheet3").Name="C"
XL.Sheets("A").Range("A1").CopyFromRecordset RST
rst.close
Set RST=CurrentDB.OpenRecordset("B")
XL.Sheets("B").Range("A1").CopyFromRecordset RST
rst.close
Set RST=CurrentDB.OpenRecordset("C")
XL.Sheets("C").Range("A1").CopyFromRecordset RST
rst.close
XL.ActiveWorkbook.Save
XL.ActiveWorkbook.Close
XL.Quit
Set XL=Nothing

HTH
- Turtle


Could I have a sample code of doing this in access/excel?

tanx,
arni
-----Original Message-----
This can be coded using Automation of Excel and DAO's RecordsetCopy command.

HTH
- Turtle

Please advise how to output different tables in one excel
file? The output should be saves in one excel file but
will have different sheet names based on the table names.
For example, the database have A, B, and C tables. I
would like to saved these into 1 excel file having 3
sheets namely A, B and C.

Please advise how to do this in access?

Help is very much appreciated.

arni :]


.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top