Incorrect output path and file name of PDF file.
The FileToPDF() method which is an API of Acrobat Distiller may not work properly. The FileToPDF() method is executed by VBA script of Microsoft Excel, and the source code is as follows.
----------VBA script start----------
Option Explicit
Const m_strDistillerProgID = "pdfdistiller.pdfdistiller.1"
Sub Button1_Click()
CreatePDF2 ActiveSheet.Range("D2").Value, ActiveSheet.Range("D3").Value
End Sub
Function CreatePDF2(szPSFilePath As String, strFullPathOfPDFFile As String) As Boolean
Dim DistillerObj As Object
ActiveSheet.PrintOut copies:=1, PrToFileName:=szPSFilePath
Set DistillerObj = CreateObject(m_strDistillerProgID)
DistillerObj.FileToPDF szPSFilePath, strFullPathOfPDFFile, ""
Set DistillerObj = Nothing
End Function
----------VBA script end----------
Usually, the PDF file is created in the path in strFullPathOfPDFFile. (expected behavior)
However, if the VBA script is executed while printing another file with Adobe PDF, the PDF file is created in the path (including file name) of another file being printed. (unexpected behavior)
Would you teach me the cause and hot to deal with it?
Note:
When the PDF file is created in incorrect path, the Post Script file was created in correct path.
I confirmed this problem in Adobe Acrobat Pro DC (version 2015.006.30033) and 2017 (version 2017.011.30078).
Thank you for your consideration.
