Hello folks- I need some help on a file that is being exported to excel. I have a button that does the following
The problem is that there is no formatting to the excel file that is created. I need to have time and date formatted for seperate colums.
Is there any way to do that? I'm not at a programmer so if the answer is obvious please don't laugh Cheers to anyone who can help. -Tom
Code:
Private Sub cmdExportToExcel_Click()
On Error GoTo Err_cmdExportToExcel_Click
Dim strQueryName As String
Dim strExcelDetail As String
Dim strDTSaved As String
strDTSaved = Format(DATE, "ddMM") ' Date and Time string to add on the "save as name".
strQueryName = "LightlogExportToExcel"
'#### If you do not want to use the date and time in the file name then put a ' in front of it.
strExcelDetail = "c:\temp\ Light Log" & " " & strDTSaved & ".xls" ' This excel file will be saved as C:\Temp\Output Current Date and Time .xls
'### If you want to use this line of code (No time and date in the file name) then remove the ' at the front of the code.
'strExcelDetail = "C:\Temp\Output"
DoCmd.OutputTo acQuery, strQueryName, "MicrosoftExcel(*.xls)", strExcelDetail, True, ""
Exit_cmdExportToExcel_Click:
Exit Sub
Err_cmdExportToExcel_Click:
MsgBox Err.Description
Resume Exit_cmdExportToExcel_Click
End Sub
The problem is that there is no formatting to the excel file that is created. I need to have time and date formatted for seperate colums.
Is there any way to do that? I'm not at a programmer so if the answer is obvious please don't laugh Cheers to anyone who can help. -Tom