Hi All,
Wondering if anyone has any experience of this, fault finding I proving to be difficult.
I have a database in Access, which then output to an excel sheet and them save as PDF.
Access writes a line in one tab of Excel, which then auto populates a template (like a certificate). Access then Exports the excel as a PDF using "ActiveWorkbook.ExportAsFixedFormat" function and then loops to the next line.
This is then on a loop which continues to write each line to the excel document.
When I have the Excel sheet open, I can see the data being written and then over written by the next line. The program publishes the PDF's, but when I open the PDFs, they are all blank.
The fact that the files are being published, means that the function is correct, so I suspect a timing issue???
Here is my code:
DoCmd.RunSQL ("SELECT Data.* INTO tbl_Temp FROM tbl_Data WHERE [tbl_Data.Value]= " & "'" & strValue & "'")
DoCmd.TransferSpreadsheet acExport, 10, "tbl_Temp", "Location of template", False, "Data_Temp!" 'Temp REF!" 'EXPORT TO EXCEL FILE
Me.Refresh
With XL
.Workbooks.Open "Excel Location here"
'.Workbooks("Template.xlsx").Model.Refresh
'Me.Refresh
'Me.Repaint
.ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, FileName:="Location" & strValue & ".pdf"
.ActiveWorkbook.Close (False)
.Quit
End With
Thanks in advance & Best Regards
Mike
Wondering if anyone has any experience of this, fault finding I proving to be difficult.
I have a database in Access, which then output to an excel sheet and them save as PDF.
Access writes a line in one tab of Excel, which then auto populates a template (like a certificate). Access then Exports the excel as a PDF using "ActiveWorkbook.ExportAsFixedFormat" function and then loops to the next line.
This is then on a loop which continues to write each line to the excel document.
When I have the Excel sheet open, I can see the data being written and then over written by the next line. The program publishes the PDF's, but when I open the PDFs, they are all blank.
The fact that the files are being published, means that the function is correct, so I suspect a timing issue???
Here is my code:
DoCmd.RunSQL ("SELECT Data.* INTO tbl_Temp FROM tbl_Data WHERE [tbl_Data.Value]= " & "'" & strValue & "'")
DoCmd.TransferSpreadsheet acExport, 10, "tbl_Temp", "Location of template", False, "Data_Temp!" 'Temp REF!" 'EXPORT TO EXCEL FILE
Me.Refresh
With XL
.Workbooks.Open "Excel Location here"
'.Workbooks("Template.xlsx").Model.Refresh
'Me.Refresh
'Me.Repaint
.ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, FileName:="Location" & strValue & ".pdf"
.ActiveWorkbook.Close (False)
.Quit
End With
Thanks in advance & Best Regards
Mike