Link to home
Start Free TrialLog in
Avatar of rogerdjr
rogerdjrFlag for United States of America

asked on

Using Microsoft Access to add headers and footers to an adobe acrobat file and to digitally sign the file

I have an excel application that creates a cover sheet in adobe acrobat (.pdf) then prompts the user to add other pdf files to the cover sheet.

I would like to migrate the application to an access database and add the ability to automatically add a watermark with specific text ("Approved" or "Draft" etc.) and a header / footer with the saved file name, saved date and page numbers the finished file when it is saved.

Then once the file is finished, have Access automatically add a digital signature.

Has anybody talked any or all of these elements?

Thanks
Avatar of Billy_London
Billy_London

out of interest, why do you want to migrate it to Access? What advantage will Access give you as a front end?
a good product is abcpdf that can manipulate pdf's on the fly and add signatures, but if you need this done on the front end then that means you'd have to have a license for each front end. you could, however, install it on a web server, manipulate all documents on the server, and return docs to the clients through http
Avatar of rogerdjr

ASKER

I have a database that I use to track and process pdf documents received by contractors. Currently I manually add a cover sheet in Acrobat, manually insert a header and footer (manually typing the file name, etc.) then apply a signature all in acrobat.

Since I process many documents each week, I'm looking for a way to automate the process from my database.
Avatar of Jeffrey Coachman
So are you wanting to insert the Heard/Footer and the Watermark in Access? (Then create the PDF from the Access report)?

...FWIW:
The Digital Signature is an entirely different subject, and should be dealt with in a new, separate question.
No actually what I want to do is edit the PDF file from access so all pages (including those that were not created by access) have the filename in the header
This is difficult to do in a PDF, but easy in Access.

Why is using Access to do this not an option?
Documents received from contractors, vendors, etc. are delivered to me as pdf docs. We then create a cover page in access and save it as a pdf

I now manually merge the document received from the contractor with our cover page, manually insert the filename as a header, save the document and in some occaions adsd our approval with a signature in the pdf.

I was hoping to automate this whole process to operate from the access input screen.

This is the code I use from excel to merge several pdfs into one (prompting the user to add each file manually) from an excel spreadsheet

---------------------------
Sub ProcessTransmittal_Click()
'
    Dim TransmittalNo As String
    Dim AddFiles As Integer
    Dim PdfPathFile As String
   
    Dim SelectPrinterName As String

    'go to 1st cell in the row
    ActiveCell.Rows("1:1").EntireRow.Select
    ActiveCell.Offset(0, 0).Range("A1").Select
   
    'copy and paste row cell value
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    TransmittalNo = Selection.Value
   
    ActiveCell.Offset(0, 1).Range("A1:N1").Select
    Application.CutCopyMode = False
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ActiveCell.Offset(0, -1).Range("A1").Select
   
    'go to transmittal sheet and set transmittal to current record
    Sheets("Transmittal  Rvw & Apprvl").Select
    Range("B4:C4").Select
    ActiveCell.FormulaR1C1 = TransmittalNo
    Range("B5").Select
   
    If Len(Dir("R:\_0TempPrint\" & ActiveWorkbook.Name & ".pdf")) > 0 Then
On Error Resume Next
        Kill "R:\_0TempPrint\" & Dir("R:\_0TempPrint\" & ActiveWorkbook.Name & ".pdf")
    End If
   
On Error GoTo 0
   
    Application.ActivePrinter = "NowPDF Writer on Ne03:"
    ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,""NowPDF Writer on Ne03:"",,TRUE,,FALSE)"

    Do Until Len(Dir("R:\_0TempPrint\" & ActiveWorkbook.Name & ".pdf")) > 0
        If Application.Wait(Now + TimeValue("0:00:01")) Then

        End If
    Loop
           
    If Len(Dir("R:\_0TempPrint\" & Range("d40").Value)) > 0 Then
On Error Resume Next
        Kill "R:\_0TempPrint\" & Range("d40").Value
    End If
On Error GoTo 0
           
    On Error GoTo failed
    FileCopy "R:\_0TempPrint\" & ActiveWorkbook.Name & ".pdf", "R:\_0TempPrint\" & Range("d40").Value

'==================================================================================

On Error GoTo 0
   
    AddFiles = MsgBox("Do You Want to Add Files to the Cover Sheet?", vbYesNo)
   
    If AddFiles = 6 Then
        While AddFiles = 6
            Dim AcroApp As Acrobat.CAcroApp
           
            Dim Part1Document As Acrobat.CAcroPDDoc
            Dim Part2Document As Acrobat.CAcroPDDoc
           
            Dim numPages As Integer
   
            Set AcroApp = CreateObject("AcroExch.App")
   
            Set Part1Document = CreateObject("AcroExch.PDDoc")
            Set Part2Document = CreateObject("AcroExch.PDDoc")
           
            PdfPathFile = "R:\_0TempPrint\" & Range("d40").Value
            Part1Document.Open (PdfPathFile)
       
            Dim strMessage As String
            Dim startDirectory
            Dim FileName  As String
   
            strMessage = "Select a directory"
            startDirectory = "C:\Documents and Settings\Roger\My Documents"
            With Application.FileDialog(msoFileDialogOpen)
   
                .AllowMultiSelect = False
                .InitialFileName = startDirectory & "\*.pdf"
     
                If .Show = -1 Then
               
                    FileName = .SelectedItems(1)
               Else
       
                    FileName = vbNullString
                    MsgBox "No file selected"
                    Exit Sub
               End If
            End With
           
   
            Part2Document.Open (FileName)
   
            ' Insert the pages of Part2 after the end of Part1
            numPages = Part1Document.GetNumPages()
   
            If Part1Document.InsertPages(numPages - 1, Part2Document, 0, Part2Document.GetNumPages(), True) = False Then
                MsgBox "Cannot insert pages"
            End If
     
            If Part1Document.Save(PDSaveFull, "R:\_0TempPrint\" & Range("d40").Value) = False Then
                MsgBox "Cannot save the modified document"
            End If
       
            Part1Document.Close
            Part2Document.Close
   
            AcroApp.Exit
            Set AcroApp = Nothing
            Set Part1Document = Nothing
            Set Part2Document = Nothing
           
            AddFiles = MsgBox("Do You Want to Add Mores Files to the Submittal?", vbYesNo)
        Wend
    End If
     
    Sheets("Email Text").Select
    Range("A1").Select
    ActiveWindow.Zoom = 75

    PdfPathFile = "R:\_0TempPrint\" & Sheets("Transmittal  Rvw & Apprvl").Range("d40").Value
    ActiveWorkbook.FollowHyperlink PdfPathFile, NewWindow:=True

Exit Sub
failed:
   
    MsgBox "Unable to Copy File:" & vbNewLine & vbNewLine & "R:\_0TempPrint\" & Dir("R:\_0TempPrint\" & ActiveWorkbook.Name & ".pdf") & vbNewLine & vbNewLine & "R:\_0TempPrint\" & ActiveWorkbook.Name & ".pdf" & vbNewLine & vbNewLine & "R:\_0TempPrint\" & Range("d40").Value

End Sub
This falls outside my sphere of knowledge...
So if my understanding is correct, you want to now pull up data from the access database instead of cells in Excel?

Sid
that is correct
May I see a sample of the Access Database?

Sid
I'll attached the excel file I have been using - plan to convert it to a database.

Really struggling with how to add a header / footer or watermark to a pdf from vba

I'd rather not distribute the spreadsheet publicly - send me an email at Rogerm@wrdarch.com and I'll forward the file.
I'd rather not distribute the spreadsheet publicly - send me an email at Rogerm@wrdarch.com and I'll forward the file.

I am not sure if that is allowed.

See if this link steers you in the right direction.

http://forums.adobe.com/thread/578343?decorator=print&displayFullThread=true

Sid
Thanks

Your link led me to a place where I found this code which works great but leaves the acrobat doc open. I would like to save it as another name and close it.

Tried a bunch of other "code snippets" without success

Would also like to have text in a color other than black - maybe red?
----------------------------------------------------------------------------------------
Sub AddPageNumbers()
    'AddFooterPgNo.vbs
    '-----------------------------------------------
    Dim path As String

    path = "C:\1\test.pdf"

    Set APP = CreateObject("Acroexch.app")
    APP.Show
    Set avdoc = CreateObject("AcroExch.AVDoc")
    Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
   
   
    If avdoc.Open(path, "") Then
      '//write JS-Code on a variable
      Ex = "  // Set Footer PageNo centered  " & vbLf _
      & "  var Box2Width = 50  " & vbLf _
      & "  for (var p = 0; p < this.numPages; p++)   " & vbLf _
      & "   {   " & vbLf _
      & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf _
      & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf _
      & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf _
      & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf _
      & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf _
      & "         fp.value = ""Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf _
      & "         fp.textSize=6;  fp.readonly = true;  " & vbLf _
      & "         fp.alignment=""center"";  " & vbLf _
      & "     }  " & vbLf _
      & "   }  "
      '//Execute JS-Code
       AForm.Fields.ExecuteThisJavaScript Ex
    End If

    Set avdoc = Nothing
    Set APP = Nothing
End Sub
I have not experimented with Adobe much but doesn't "avdoc" let you save and close the file?

something like this

avdoc.Save
avdoc.Close

before the line

Set avdoc = Nothing

Sid
Tried

avdoc.Save
avdoc.Close

before the line

Set avdoc = Nothing


The code hangs at avdoc.save and I get the error message - this "Object doesn't support this property or method"
SiddharthRout,

Just FYI

<I'd rather not distribute the spreadsheet publicly - send me an email at Rogerm@wrdarch.com and I'll forward the file.
I am not sure if that is allowed.>

The issue with this is two-fold:
1. Being that this is a public forum, it exposes your email to everyone who views this question.
2. Using personal email to solve issues locks other Experts out of the process, so in that case the Q really will have very little value in a public forum if part of the solution is done by personal email.
Make sense?

Remember, most requests for sample files are just that...
Requests for "sample" files.
In other words, a file that simply illustrates the issue.

JeffCoachman
Jeff

I'm sending the file hope it helps
08012-355-Abbott-Street-Shop-dra.xlsm
Jeff: I am aware of those reasons. :) I was referring in terms of 'Rule and Regulations" :)

rogerdjr:

I cannot test it. What happens when you do this?

Sub AddPageNumbers()
    'AddFooterPgNo.vbs
    '-----------------------------------------------
    Dim path As String, PDDoc

    path = "C:\1\test.pdf"

    Set app = CreateObject("Acroexch.app")
    app.Show
    Set AVDoc = CreateObject("AcroExch.AVDoc")
    Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
    
    booleanresult = AVDoc.Open(path, "")
    If booleanresult = True Then
        PDDoc = AVDoc.GetPDDoc
'02-22-2011    If avdoc.Open(path, "") Then
      '//write JS-Code on a variable'
      Ex = "  // Set Footer PageNo centered  " & vbLf _
      & "  var Box2Width = 50  " & vbLf _
      & "  for (var p = 0; p < this.numPages; p++)   " & vbLf _
      & "   {   " & vbLf _
      & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf _
      & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf _
      & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf _
      & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf _
      & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf _
      & "         fp.value = ""Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf _
      & "         fp.textSize=6;  fp.readonly = true;  " & vbLf _
      & "         fp.alignment=""center"";  " & vbLf _
      & "     }  " & vbLf _
      & "   }  "
      '//Execute JS-Code
       AForm.Fields.ExecuteThisJavaScript Ex
    End If

    PDDoc.Save 1, path
    PDDoc.Close
    
    Set PDDoc = Nothing
    Set AVDoc = Nothing
    Set app = Nothing
End Sub

Open in new window


Sid
Sid,

Oh, Sorry...

Since you did not encapsulate the direct quote from the OP, like so:
  <I'd rather not distribute the spreadsheet publicly - send me an email at Rogerm@wrdarch.com and I'll forward the file.>

...I thought you made that statement...

Jeff
That's ok :)

Sid
SiddharthRout

It stalls at   line 15  PDDoc = avdoc.GetPDDoc

Error message says "Object doesn't support this property or method"
What happens when you try this?

Sub AddPageNumbers()
    'AddFooterPgNo.vbs
    '-----------------------------------------------
    Dim path As String, AcroAVDoc As Object, AcroPDDoc As Object

    path = "C:\1\test.pdf"

    Set app = CreateObject("Acroexch.app")
    app.Show
    Set AVDoc = CreateObject("AcroExch.AVDoc")
    Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
    
    booleanresult = AVDoc.Open(path, "")
    If booleanresult = True Then
        Set AcroAVDoc = AcroApp.GetActiveDoc
        Set AcroPDDoc = AcroAVDoc.GetPDDoc
'02-22-2011    If avdoc.Open(path, "") Then
      '//write JS-Code on a variable'
      Ex = "  // Set Footer PageNo centered  " & vbLf _
      & "  var Box2Width = 50  " & vbLf _
      & "  for (var p = 0; p < this.numPages; p++)   " & vbLf _
      & "   {   " & vbLf _
      & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf _
      & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf _
      & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf _
      & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf _
      & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf _
      & "         fp.value = ""Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf _
      & "         fp.textSize=6;  fp.readonly = true;  " & vbLf _
      & "         fp.alignment=""center"";  " & vbLf _
      & "     }  " & vbLf _
      & "   }  "
      '//Execute JS-Code
       AForm.Fields.ExecuteThisJavaScript Ex
    End If

    AcroPDDoc.Save 1, path
    AcroPDDoc.Close
    
    Set AcroPDDoc = Nothing
    Set AcroAVDoc = Nothing
    Set AVDoc = Nothing
    Set app = Nothing
End Sub

Open in new window


Sid
I'm out of office today will try it tomorrow

Thanks
Made one minor change and it works. The only additional step I'd like to add is to close the acrobat document.

I may also want to save as another name and close, I found that editing the path in "AcroPDDoc.Save 1, path" I can save as another name.

But I can't get seem to get the "AcroPDDoc.Close" to close the acrobat document.

Thanks so much for all your help, this has been a very interesting process. Can you suggest a source for some of the 'Acrobat' commands that seem to apply here?

Thanks again

Roger
--------------------------------------------------------------------------

Sub AddPageNumbers()
    'AddFooterPgNo.vbs
    '-----------------------------------------------
    Dim path As String, AcroAVDoc As Object, AcroPDDoc As Object, Path1 As String

    path = "C:\1\test.pdf"
    Path1 = "C:\1\test-edited.pdf"
    Set App = CreateObject("Acroexch.app")
    App.Show
    Set AVDoc = CreateObject("AcroExch.AVDoc")
    Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
   
    booleanresult = AVDoc.Open(path, "")
    If booleanresult = True Then
        Set AcroAVDoc = App.GetActiveDoc
'02-25-2011        Set AcroAVDoc = AcroApp.GetActiveDoc
        Set AcroPDDoc = AcroAVDoc.GetPDDoc
'02-22-2011    If avdoc.Open(path, "") Then
      '//write JS-Code on a variable'
      Ex = "  // Set Footer PageNo centered  " & vbLf _
      & "  var Box2Width = 50  " & vbLf _
      & "  for (var p = 0; p < this.numPages; p++)   " & vbLf _
      & "   {   " & vbLf _
      & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf _
      & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf _
      & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf _
      & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf _
      & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf _
      & "         fp.value = ""Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf _
      & "         fp.textSize=6;  fp.readonly = true;  " & vbLf _
      & "         fp.alignment=""center"";  " & vbLf _
      & "     }  " & vbLf _
      & "   }  "
      '//Execute JS-Code
       AForm.Fields.ExecuteThisJavaScript Ex
    End If

    AcroPDDoc.Save 1, path

    AcroPDDoc.Close
   
    Set AcroPDDoc = Nothing
    Set AcroAVDoc = Nothing
    Set AVDoc = Nothing
    Set App = Nothing
End Sub
Add this line

AcroAVDoc.Close

after

AcroPDDoc.Close

and now try.

Sid
In fact try this

Replace

    AcroPDDoc.Save 1, path

    AcroPDDoc.Close
   
    Set AcroPDDoc = Nothing
    Set AcroAVDoc = Nothing
    Set AVDoc = Nothing
    Set App = Nothing

with

    AcroPDDoc.Save 1, path

    AcroPDDoc.Close
    AcroAVDoc.Close
    AVDoc.Close
    App.Quit

    Set AcroPDDoc = Nothing
    Set AcroAVDoc = Nothing
    Set AVDoc = Nothing
    Set App = Nothing

Open in new window


Sid
Wish I had a reference for some of this code, I'm really working in the dark and cannot do much but just plug-in your suggestions.

With this change, the program hangs with a message "Wrong Number of Arguments or invalid property assignment" at AcroAVDoc.Close

Thanks for all the help


I also don't have any ready reference with me and I am relying on you to test it for me as I can't test it. :)

Try this

AcroAVDoc.Close(True)

Sid
we almost have it:

Made these changes:


    AcroPDDoc.Close
    AcroAVDoc.Close (True)
    AVDoc.Close (True)
    app.Close
   
    Set AcroPDDoc = Nothing
    Set AcroAVDoc = Nothing
    Set AVDoc = Nothing
    Set app = Nothing

hangs at app.close, tried app.quit, app.close(true) and app.quit(true)

No louck

Leaves a blank acrobat file but saves and closes the edited file

Thanks for all your help
Try

app.Exit

Sid
That worked - thanks, leaves acrobat open , but that is just a minor nuisance.

on occasion it hangs up on "Set AcroPDDoc = AcroAVDoc.GetPDDoc" but I think that is a result of numerous "debugs" and opening and closing applications.

Thanks for all your help.

ll tset drive for the day before I close this one.

This is the code I ended up with:

Sub AddPageNumbers()
    'AddFooterPgNo.vbs
    '-----------------------------------------------
    Dim path As String, AcroAVDoc As Object, AcroPDDoc As Object, Path1 As String

    path = "C:\1\test.pdf"
    Path1 = "C:\1\test-edited.pdf"
   
    FileName = "C:/1/This is a Test.pdf"
    Set app = CreateObject("Acroexch.app")
    app.Show
    Set AVDoc = CreateObject("AcroExch.AVDoc")
    Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
   
    booleanresult = AVDoc.Open(path, "")
   
    If booleanresult = True Then
        Set AcroAVDoc = app.GetActiveDoc
        Set AcroPDDoc = AcroAVDoc.GetPDDoc
      ex1 = "  // Set Footer PageNo centered  " & vbLf & "  var Box2Width = 500  " & vbLf & "  for (var p = 0; p < this.numPages; p++)   " & vbLf & "   {   " & vbLf & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf & "         fp.value = """
      ex1 = ex1 & FileName & " " & Month(Now) & "/" & Day(Now) & "/" & Year(Now) & " " & Hour(Now) & ":" & Minute(Now)
      ex1 = ex1 & " -- Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf & "         fp.textSize=6; fp.textColor = color.red;  fp.readonly = true;  " & vbLf & "         fp.alignment=""left"";  " & vbLf & "     }  " & vbLf & "   }  "

      '//Execute JS-Code
       AForm.Fields.ExecuteThisJavaScript ex1
    End If

    AcroPDDoc.Save 1, Path1

    AcroPDDoc.Close
    AcroAVDoc.Close (True)
    AVDoc.Close (True)
    app.Exit
   
    Set AcroPDDoc = Nothing
    Set AcroAVDoc = Nothing
    Set AVDoc = Nothing
    Set app = Nothing
End Sub

Sure. let me know if you face any other glitches.

Sid
Sid

The application hangs on the command "Set AcroPDDoc = AcroAVDoc.GetPDDoc" with the error message "Object variable or with block not set"

This doesn't happen the 1st time I run it, even if another acrobat file is open.

It does happen the second time I run the application, when the first run leaves acrobat open with no document (blank black screen) or if I open acrobat without a document (blank black screen) and then run the application.

    Set AcroPDDoc = Nothing
    Set AcroAVDoc = Nothing
    Set AVDoc = Nothing
    Set app = Nothing

Any ideas?

It looks like I need a way to close the acrobat "blank black screen" before starting the application. I tried putting these commands at the beginning of the application, but that didn't do the trick.
The code .Exit should have closed it but it doesn't. Ok try this slight variation of your code.

Sub AddPageNumbers()
    'AddFooterPgNo.vbs
    '-----------------------------------------------
    Dim path As String, AcroAVDoc As Object, AcroPDDoc As Object, Path1 As String

    path = "C:\1\test.pdf"
    Path1 = "C:\1\test-edited.pdf"
   
    Filename = "C:/1/This is a Test.pdf"
    
    '~~> Establish an existing application object
    On Error Resume Next
    Set app = GetObject(, "Acroexch.app")
    
    '~~> If not found then create new instance
    If Err.Number <> 0 Then
        Set app = CreateObject("Acroexch.app")
    End If
    Err.Clear
    On Error GoTo 0
    
    app.Show
    Set AVDoc = CreateObject("AcroExch.AVDoc")
    Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
   
    booleanresult = AVDoc.Open(path, "")
   
    If booleanresult = True Then
        Set AcroAVDoc = app.GetActiveDoc
        Set AcroPDDoc = AcroAVDoc.GetPDDoc
      ex1 = "  // Set Footer PageNo centered  " & vbLf & "  var Box2Width = 500  " & vbLf & "  for (var p = 0; p < this.numPages; p++)   " & vbLf & "   {   " & vbLf & "    var aRect = this.getPageBox(""Crop"",p);  " & vbLf & "    var TotWidth = aRect[2] - aRect[0]  " & vbLf & "     {  var bStart=(TotWidth/2)-(Box2Width/2)  " & vbLf & "         var bEnd=((TotWidth/2)+(Box2Width/2))  " & vbLf & "         var fp = this.addField(String(""xftPage""+p+1), ""text"", p, [bStart,30,bEnd,15]);   " & vbLf & "         fp.value = """
      ex1 = ex1 & Filename & " " & Month(Now) & "/" & Day(Now) & "/" & Year(Now) & " " & Hour(Now) & ":" & Minute(Now)
      ex1 = ex1 & " -- Page: "" + String(p+1)+ ""/"" + this.numPages;  " & vbLf & "         fp.textSize=6; fp.textColor = color.red;  fp.readonly = true;  " & vbLf & "         fp.alignment=""left"";  " & vbLf & "     }  " & vbLf & "   }  "

      '//Execute JS-Code
       AForm.Fields.ExecuteThisJavaScript ex1
    End If

    AcroPDDoc.Save 1, Path1

    AcroPDDoc.Close
    AcroAVDoc.Close (True)
    AVDoc.Close (True)
    app.Exit
   
    Set AcroPDDoc = Nothing
    Set AcroAVDoc = Nothing
    Set AVDoc = Nothing
    Set app = Nothing
End Sub

Open in new window


Sid
Still not quite there

I added a message box to see what error I am getting the number is 429 (whether acrobat is open or not)

Stills hangsup like before - the second time I run the APP

    '~~> If not found then create new instance
    If Err.Number <> 0 Then
        MsgBox Err.Number
        Set App = CreateObject("Acroexch.app")
    End If
    Err.Clear
    On Error GoTo 0
   
    App.Show
    Set AVDoc = CreateObject("AcroExch.AVDoc")
    Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
   
    booleanresult = AVDoc.Open(path, "")
   
    If booleanresult = True Then
        Set AcroAVDoc = App.GetActiveDoc
        Set AcroPDDoc = AcroAVDoc.GetPDDoc
Guess I will have to install acrobat after all to test it.

Which version do you have?

Sid
version 9

Thanks I wish I was more help with trouble shooting
ASKER CERTIFIED SOLUTION
Avatar of SiddharthRout
SiddharthRout
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Worked Really Great - Thanks a Million!!!!!!!!!!
SiddharthRout  was VERY HELPFUL

Really put in an extra effort to help solve a very complicated problem.
No thanks to you... I was thinking of buying Adobe for a long time. You just help me speed up the process... lolzzz

Sid