N
New2Access
Folks,
I am very new to using automation in VBA, but need to convert some .xls &
..doc files to pdf format using access (long story).
Anyway, through searching the web, I was able to hack together the code
below, which in the end seams to get me to where I need to be, but I have
the following 3 questions/problems (hoping someone can help).
#1 - After I run this, acrodist.exe & acrotray.exe still hang around as a
process in my task manager. I can't see where I am not closing
something. Anyone see why this still hangs up?
#2 - As the procedure runs, at different times, acrobat windows are
interacting (popping up) with the user (such as "Now Printing
Page....."), can I get it so these pop-ups never appears on the screen
and the user never gets a chance to cancel or close while procedure is
running?
#3 - Just looking for general comments on the code. As I said, I
somewhat "hacked" this together using many different code samples and
resources from the web, but ultimately I want some people who work with
me to use this and I want it to be stable, so general feedback would be
appreciated.
======================================================
Public Sub CreatePDF()
On Error GoTo Proc_Error
Dim objAcroApp As Acrobat.CAcroApp
Dim objAVDoc As Acrobat.CAcroAVDoc
Dim objAcroDoc As Acrobat.CAcroPDDoc
Dim IsSuccess As Boolean
Set objAcroApp = CreateObject("AcroExch.App")
Set objAVDoc = CreateObject("AcroExch.AVDoc")
IsSuccess = objAVDoc.Open("c:\Temp\blah2.doc", "")
Set objAVDoc = objAcroApp.GetActiveDoc
If objAVDoc.IsValid Then
Set objAcroDoc = objAVDoc.GetPDDoc
If objAcroDoc.Save(1 Or 4 Or 32, "c:\Temp\work.pdf") <> True Then
MsgBox "Failed to save"
End If
objAcroDoc.Close
End If
objAVDoc.Close True
objAcroApp.Exit
Proc_Exit:
Set objAcroDoc = Nothing
Set objAVDoc = Nothing
Set objAcroApp = Nothing
MsgBox "Complete"
Exit Sub
Proc_Error:
MsgBox Err.Description
Resume Proc_Exit
End Sub
============================================================
Thanks ahead of time.
I am very new to using automation in VBA, but need to convert some .xls &
..doc files to pdf format using access (long story).
Anyway, through searching the web, I was able to hack together the code
below, which in the end seams to get me to where I need to be, but I have
the following 3 questions/problems (hoping someone can help).
#1 - After I run this, acrodist.exe & acrotray.exe still hang around as a
process in my task manager. I can't see where I am not closing
something. Anyone see why this still hangs up?
#2 - As the procedure runs, at different times, acrobat windows are
interacting (popping up) with the user (such as "Now Printing
Page....."), can I get it so these pop-ups never appears on the screen
and the user never gets a chance to cancel or close while procedure is
running?
#3 - Just looking for general comments on the code. As I said, I
somewhat "hacked" this together using many different code samples and
resources from the web, but ultimately I want some people who work with
me to use this and I want it to be stable, so general feedback would be
appreciated.
======================================================
Public Sub CreatePDF()
On Error GoTo Proc_Error
Dim objAcroApp As Acrobat.CAcroApp
Dim objAVDoc As Acrobat.CAcroAVDoc
Dim objAcroDoc As Acrobat.CAcroPDDoc
Dim IsSuccess As Boolean
Set objAcroApp = CreateObject("AcroExch.App")
Set objAVDoc = CreateObject("AcroExch.AVDoc")
IsSuccess = objAVDoc.Open("c:\Temp\blah2.doc", "")
Set objAVDoc = objAcroApp.GetActiveDoc
If objAVDoc.IsValid Then
Set objAcroDoc = objAVDoc.GetPDDoc
If objAcroDoc.Save(1 Or 4 Or 32, "c:\Temp\work.pdf") <> True Then
MsgBox "Failed to save"
End If
objAcroDoc.Close
End If
objAVDoc.Close True
objAcroApp.Exit
Proc_Exit:
Set objAcroDoc = Nothing
Set objAVDoc = Nothing
Set objAcroApp = Nothing
MsgBox "Complete"
Exit Sub
Proc_Error:
MsgBox Err.Description
Resume Proc_Exit
End Sub
============================================================
Thanks ahead of time.