J
Jeff
Sorry if I posted this on the wrong forum but I am having some difficulty
attempting the following and could use some help....
I have a query which I am exporting to several worksheets within one excel
spreadsheet using the TransferSpreadSheet command and I am wondering if there
is also a way to format the data in Excel when I send it to each worksheet...
What I would like to do is to make the "header bold text", size the columns
to "auto fit", and "center the text" in all columns.
My code for exporting the query (which is set up to dump a seperate record
from a table into it's own worsheet) is as follows:
----------------------------------------------------------------------------
DoCmd.TransferSpreadsheet acExport, cSpreadsheetTypeExcel9,
strTemp, "C:\" & strFileName & ".xls"
----------------------------------------------------------------------------
I recorded the following macro within excel on one worksheet but I am not
sure how to call this from access to format each worksheet as it is created
in my access code:
-----------------------------------------------
Sub cleanup()
'
' cleanup Macro
' This macro bolds the heading, autofits columns and centers text
'
' Keyboard Shortcut: Ctrl+z
'
Rows("1:1").Select
Selection.Font.Bold = True
Cells.Select
Selection.Columns.AutoFit
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub
-----------------------------------------------
How do I run this from access so that this formatting occurs with every
worksheet
that I create with my transferspreadsheet function?
Thanks
attempting the following and could use some help....
I have a query which I am exporting to several worksheets within one excel
spreadsheet using the TransferSpreadSheet command and I am wondering if there
is also a way to format the data in Excel when I send it to each worksheet...
What I would like to do is to make the "header bold text", size the columns
to "auto fit", and "center the text" in all columns.
My code for exporting the query (which is set up to dump a seperate record
from a table into it's own worsheet) is as follows:
----------------------------------------------------------------------------
DoCmd.TransferSpreadsheet acExport, cSpreadsheetTypeExcel9,
strTemp, "C:\" & strFileName & ".xls"
----------------------------------------------------------------------------
I recorded the following macro within excel on one worksheet but I am not
sure how to call this from access to format each worksheet as it is created
in my access code:
-----------------------------------------------
Sub cleanup()
'
' cleanup Macro
' This macro bolds the heading, autofits columns and centers text
'
' Keyboard Shortcut: Ctrl+z
'
Rows("1:1").Select
Selection.Font.Bold = True
Cells.Select
Selection.Columns.AutoFit
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub
-----------------------------------------------
How do I run this from access so that this formatting occurs with every
worksheet
that I create with my transferspreadsheet function?
Thanks