K
Ken
I'm getting a File Doesn't Exist error when I try to Call this function from
within my Email function. Sometimes I'm sure it is a timing issue where the
email is trying to attach this file before it is finished being created.
Would some one be kind enough to supply me with some timer code that tests
and waits for the file to be created before continuing?
Thanks,
Ken
**************************************
Public Function PrintToPDF()
Dim PSFileName As String
Dim PDFFileName As String
Dim DistillerCall As String
Dim ReturnValue As Variant
Application.StatusBar = "Creating PDF of Calendar"
' Set folder path and file names
Dim DocsFolder As String
DocsFolder = CreateObject("WScript.Shell").SpecialFolders("MyDocuments")
PSFileName = DocsFolder & "\PigeonTrainingCalendar.PS"
PDFFileName = DocsFolder & "\PigeonTrainingCalendar.PDF"
'If the files already exist, delete them:
If Dir(PSFileName) <> "" Then Kill (PSFileName)
If Dir(PDFFileName) <> "" Then Kill (PDFFileName)
'The Sendkeys characters are the full path and filename, followed by the
"Enter" key.
' These are buffered until the "print to file" screen appears:
SendKeys PSFileName & "{ENTER}", False
'Print the document to PDF
ActiveSheet.PrintOut , PrintToFile:=True
'NEED TIMER HERE I THINK
'Add double quotes around the PS filename and PDF filename:
PSFileName = Chr(34) & PSFileName & Chr(34)
PDFFileName = Chr(34) & PDFFileName & Chr(34)
DistillerCall = "C:\Program Files\Adobe\Acrobat 8\Acrobat\Acrodist.exe" & _
" /n /q /o" & PDFFileName & " " & PSFileName
'Call the Acrobat Distiller to distill the PS file. ReturnValue is zero
'if the application doesn't open correctly:
ReturnValue = Shell(DistillerCall, vbNormalFocus)
If ReturnValue = 0 Then MsgBox "Creation of " & PDFFileName & "failed."
End Function
*************************************
within my Email function. Sometimes I'm sure it is a timing issue where the
email is trying to attach this file before it is finished being created.
Would some one be kind enough to supply me with some timer code that tests
and waits for the file to be created before continuing?
Thanks,
Ken
**************************************
Public Function PrintToPDF()
Dim PSFileName As String
Dim PDFFileName As String
Dim DistillerCall As String
Dim ReturnValue As Variant
Application.StatusBar = "Creating PDF of Calendar"
' Set folder path and file names
Dim DocsFolder As String
DocsFolder = CreateObject("WScript.Shell").SpecialFolders("MyDocuments")
PSFileName = DocsFolder & "\PigeonTrainingCalendar.PS"
PDFFileName = DocsFolder & "\PigeonTrainingCalendar.PDF"
'If the files already exist, delete them:
If Dir(PSFileName) <> "" Then Kill (PSFileName)
If Dir(PDFFileName) <> "" Then Kill (PDFFileName)
'The Sendkeys characters are the full path and filename, followed by the
"Enter" key.
' These are buffered until the "print to file" screen appears:
SendKeys PSFileName & "{ENTER}", False
'Print the document to PDF
ActiveSheet.PrintOut , PrintToFile:=True
'NEED TIMER HERE I THINK
'Add double quotes around the PS filename and PDF filename:
PSFileName = Chr(34) & PSFileName & Chr(34)
PDFFileName = Chr(34) & PDFFileName & Chr(34)
DistillerCall = "C:\Program Files\Adobe\Acrobat 8\Acrobat\Acrodist.exe" & _
" /n /q /o" & PDFFileName & " " & PSFileName
'Call the Acrobat Distiller to distill the PS file. ReturnValue is zero
'if the application doesn't open correctly:
ReturnValue = Shell(DistillerCall, vbNormalFocus)
If ReturnValue = 0 Then MsgBox "Creation of " & PDFFileName & "failed."
End Function
*************************************