unclesvenno
Programmer
Hello All,
I have a button on a form which exports the result of a query to an Excel spreadsheet with the following code:
I would like to have the Excel spreadsheet formatted.
1 - Do I need to format the spreadsheet after I have exported the data?
or
2 - Can I export the data to a templated spreadsheet?
if so, how?
Thanks again,
Uncle Svenno
I have a button on a form which exports the result of a query to an Excel spreadsheet with the following code:
Code:
Private Sub cmdExport_Click()
On Error GoTo Err_cmdExport_Click
' Local Variables
Dim db As Database
Dim qDef As QueryDef
Dim fPath As String
Dim strFilter As String
Dim strSaveFileName As String
'Ask for SaveFileName
strFilter = ahtAddFilterItem("", "Excel Files (*.xls)", "*.xls")
strSaveFileName = ahtCommonFileOpenSave(OpenFile:=False, Filter:=strFilter, _
Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY)
'Test if Save As... cancelled
If strSaveFileName = "" Then
GoTo Exit_cmdExport_Click
End If
'Save to file
Set db = CurrentDb
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, ("FileRepOrder"), strSaveFileName, True
Set qDef = Nothing
Set db = Nothing
'Indicate task complete
MsgBox "File " & strSaveFileName & " successfully saved"
Exit_cmdExport_Click:
Exit Sub
Err_cmdExport_Click:
MsgBox Err.Number & " " & Err.Description, vbCritical, "Error"
Resume Exit_cmdExport_Click
End Sub
I would like to have the Excel spreadsheet formatted.
1 - Do I need to format the spreadsheet after I have exported the data?
or
2 - Can I export the data to a templated spreadsheet?
if so, how?
Thanks again,
Uncle Svenno