New Forum | Previous | Next | (P-PDF) Developers
Topic: IAC: .Doc to PDF
Conf: (P-PDF) Developers, Msg: 95126
Date: 8/26/2003 01:36 AM
When I try to run the following code from Visual Basic, the PDFMaker successfully initializes and the "Creating Adobe PDF" dialog/status bar comes up. But the status bar only reaches one "blip", the Acrobat window hangs for about a minute, and strangely enough, Word opens the document and gives programmatic control directly to the GUI without running the PDFMaker macro. The PDF is not successfully created after it's all done, and Word stays open. If I try to do this using "Open" in the Acrobat window (non-programmatically) everything works out fine - same machine, same Word installation etc. Is there something I'm missing? I've tried it with avApp locked and unlocked, and I've tried opening it as a PDDoc and as an AVDoc. The PDDoc doesn't even initialize the PDFMaker. Assume all file name calculations are correct, and disregard the DAO. I tried stepping through with debug mode and all the variables turn out right. This seems to be some sort of internal problem.
Private Sub Administer_Click()
Dim fa As String, ga As String, rs As Object
Set rs = Me.MailAttachments.Recordset
ga = InputBox("Enter the description for the new attachment.")
fa = FSQueryForFile(Me)
fn = Left(fa, InStr(1, fa, "."))
fn = Trim(Right(fn, Len(fn) - InStrRev(fn, "\")))
If MsgBox("Are you sure you want to add this entry to the list of attachments? This operation can only be reversed by an Administrator.", vbOKCancel, "Confirmation") = vbOK Then
rs.Fields(0) = ga
rs.Fields(1) = GSECURITY.getDrivePath & "System\" & fn & "pdf"
Set Me.MailAttachments.Recordset = Me.MailAttachments.Recordset
'Start paying attention here*******************
Dim avDoc As CAcroAVDoc, PDDoc As CAcroPDDoc, avApp As CAcroApp
Set avApp = CreateObject("AcroExch.App")
avApp.Lock "Subprocedure, Administer"
Set avDoc = CreateObject("AcroExch.AVDoc")
Set PDDoc = avDoc.GetPDDoc
pdDoc.Save PDSaveFull, GSECURITY.getDrivePath & "System\" & fn & "pdf"
'Dereference avoids protection fault, lol
Set PDDoc = Nothing
Set avDoc = Nothing
Set avApp = Nothing