I have made the same kind of observations as NikolausM. I have discovered that if the app sits idle for 7 minutes and 59 seconds or less, it is able to store the pdf within C:\Temp . If it sits idle for 8 minutes and 0 seconds or more, it cannot store
the pdf within C:\Temp. The application simply crashes without error during its attempt to convert the report to pdf, and store it.
The time threshold's given are as measured from the moment the application is opened. So, I have 7 minutes and 59 seconds from the time the application is opened to created and store the pdf, via DoCmd.OutputTo. After that time, if I attempt it, the app
crashes.
I am running Office Pro Plus 2016 (32 bit) on Windows 10(64 bit). I am starting an accdb file from a bat file using START and a /runtime flag.
In the Form_Open event handler of the applications Display Form , I ask to store the report as a pdf in C:\Temp. But first, I have the code pause for a set number of seconds, an amount which I varied during my tests.
Here is a code sample that will give a good idea of how the test was done.
'**************************************
Within Display Form:
Private Sub Form_Open(Cancel As Integer)
Const secondsToSleep As Long = 479
testReportToPdfStorage secondsToSleep
End Sub
Public Sub testReportToPdfStorage(secondsToSleep As Long)
Dim millisecToSleep As Long
Dim fullPathToStoredFile As String
millisecToSleep = secondsToSleep * 1000
fullPathToStoredFile = "C:\Temp\" + "Statement-" & secondsToSleep & ".pdf"
PauseExecution millisecToSleep 'a call to a subroutine within libPauseExecution
DoCmd.OutputTo acOutputReport, "rptBillingStatement", acFormatPDF, fullPathToStoredFile, False, "", 0, acExportQualityPrint
End Sub
'**************************************
'libPauseExecution: Not much to it
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Sub PauseExecution(lngMilliseconds As Long)
Sleep lngMilliseconds
End Sub
I have looked for clues as to cause in the Windows Event Log, but have found nothing. In addition, I have done some studying of ProcessMonitor logs, but have come to no conclusion what might be causing this time dependent crash to occur. This is a very
repeatable problem.