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

  • Thread starter Thread starter arni
  • Start date Start date
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 :]
 
This can be coded using Automation of Excel and DAO's RecordsetCopy command.

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 :]


.
 
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 :]


.
 
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 :]


.


.
 
Back
Top