Why are bookmarks generated intermittently when PDF created using EXCEL VBA?

I have Windows 7 installed and Acrobat Pro 9 installed. There is an EXCEL application that creates PDFs successfully. Howver, bookmarks are generated sometimes and sometimes they are not generated. This happens without changing any code. I am at my wits end and would appreciate any assistance. Here is the code:
Function PDF_PRINTING_2007()
Dim V_NBR_OF_RPTS As Integer
Dim stdPrinter As String
Dim Prints, z, n As Integer
Dim pdfile, pdtitle As Boolean
Dim V_RPT_ARRAY(800) As String
Dim V_RPT_PAGES_ARRAY(800) As Long
    Application.ScreenUpdating = False
    V_NBR_OF_RPTS = 0
    Erase V_RPT_ARRAY
    Erase V_RPT_PAGES_ARRAY
    V_PLANT_SUMMARY = ""
    Sheets("TABLE OF CONTENTS").Activate
    V_TOC_LAST_ROW = Cells(65536, 7).End(xlUp).Row
    V_TOC_ROW = 5
    Do Until V_TOC_ROW > V_TOC_LAST_ROW
        If Cells(V_TOC_ROW, 7) = "Y" Then
            V_RPT = Cells(V_TOC_ROW, 2).Value
            If V_RPT = "PLANT SUMMARY" Then
                V_PLANT_SUMMARY = "Y"
            End If
            If V_RPT = UCase("SUMMARY CAGE & HOIST") Or V_RPT = UCase("PLANT SUMMARY") Then
            Else
                V_NBR_OF_RPTS = V_NBR_OF_RPTS + 1
                V_RPT_ARRAY(V_NBR_OF_RPTS) = V_RPT
                V_RPT_PAGES_ARRAY(V_NBR_OF_RPTS) = Cells(V_TOC_ROW, 6)
            End If
        End If
        V_TOC_ROW = V_TOC_ROW + 1
    Loop
    Sheets("SYS - USER INTERFACE").Activate
    V_RPT_PERIOD = Cells(1, 1)
    V_PLANT_NBR = Cells(1, 2)
    V_PLANT_NAME = Cells(1, 3)
    Set AcroApp = CreateObject("AcroExch.App")
    Set PDBookmark = CreateObject("AcroExch.PDBookmark")
    Set avDoc = CreateObject("AcroExch.AVDoc")
    Set pdDoc1 = CreateObject("AcroExch.PDDoc")
    Set pdDoc2 = CreateObject("AcroExch.PDDoc")
    'Print Worksheets to PDF Files
    stdPrinter = Application.ActivePrinter
    'Commented out next line for Acrobat 8.x - 1/29/2008 - CR24709 and WP25089
    ' Application.ActivePrinter = "Acrobat PDFWriter on LPT1:"
    AppendIni ("C:\temp\Sheet1.pdf")
    'Commented out next line for Acrobat 8.x - 1/29/2008 - CR24709 and WP25089
    'Sheets("COVER SHEET").PrintOut
    'Added the next 3 lines for Acrobat 8.x - 1/29/2008 - CR24709 and WP25089
    Sheets("COVER SHEET").Activate
    PageSetupFitToPage
    SaveToPDF ("C:\temp\Sheet1.pdf")
    pdDoc1.Open ("C:\temp\Sheet1.pdf")
    pdDoc1.SetInfo "Title", "Cover Sheet"
    pdDoc1.Save 1, "C:\temp\Sheet1.pdf"
    pdDoc1.Close
' The "TABLE OF CONTENTS" worksheet contains color.  Reset it to black and white.
    Application.DisplayAlerts = False
    On Error Resume Next
    Worksheets("SYS - PDF WS").Delete
'EOB change for Priority #12--Arial named range dialog box error
'  Comment out alert below
'    Application.DisplayAlerts = True
'EOB change for Priority #12 end
    Sheets("TABLE OF CONTENTS").Copy Before:=Sheets("SYS - USER INTERFACE")
    ActiveSheet.Name = "SYS - PDF WS"
'EOB change for Priority #12--Arial named range dialog box error
'  insert alert below
    Application.DisplayAlerts = True
'EOB change for Priority #12 end
    Sheets("TABLE OF CONTENTS").Activate
    V_TOC_ROW = 5
    Do Until V_TOC_ROW > V_TOC_LAST_ROW
        If Cells(V_TOC_ROW, 7) = "Y" Then
            V_RPT_NAME = Cells(V_TOC_ROW, 2)
            Cells(V_TOC_ROW, 2).Clear
            Cells(V_TOC_ROW, 2) = V_RPT_NAME
        End If
        V_TOC_ROW = V_TOC_ROW + 1
    Loop
    Cells.Select
    Selection.Font.Color = vbBlack
    Selection.Interior.Color = vbWhite
     AppendIni ("C:\temp\Sheet2.pdf")
     'Commented out next line for Acrobat 8.x - 1/29/2008 - CR24709 and WP25089
     'Sheets("TABLE OF CONTENTS").PrintOut
     'Added the next 3 lines for Acrobat 8.x - 1/29/2008 - CR24709 and WP25089
     Sheets("TABLE OF CONTENTS").Activate
     PageSetupFitToPageWidth
     SaveToPDF ("C:\temp\Sheet2.pdf")
     pdDoc2.Open ("C:\temp\Sheet2.pdf")
     pdDoc2.SetInfo "Title", "Table of Contents"
     pdDoc2.Save 1, "C:\temp\Sheet2.pdf"
     pdDoc2.Close
    Application.DisplayAlerts = False
    Worksheets("TABLE OF CONTENTS").Delete
    Sheets("SYS - PDF WS").Copy Before:=Sheets("TEMPLATE TBL OF CONTENTS")
    ActiveSheet.Name = "TABLE OF CONTENTS"
    Worksheets("SYS - PDF WS").Delete
    Application.DisplayAlerts = True
    Prints = 3
    If V_PLANT_SUMMARY = "Y" Then
        Sheets("PLANT SUMMARY").Activate
        Sheets("PLANT SUMMARY").PageSetup.LeftFooter = Now()
        Sheets("PLANT SUMMARY").PageSetup.CenterFooter = "#" & V_PLANT_NBR & " " & V_PLANT_NAME & Chr(13) & V_RPT_PERIOD
        'Sheets("PLANT SUMMARY").PageSetup.RightFooter = "Page 1"
        'eob change start here--Change #9 comment out page numbers
        'Sheets("PLANT SUMMARY").PageSetup.RightFooter = "Page " & Prints
        'eob change end
        AppendIni ("C:\temp\Sheet" & Prints & ".pdf")
        'Commented out next line for Acrobat 8.x - 1/29/2008 - CR24709 and WP25089
        'Sheets("PLANT SUMMARY").PrintOut
        'Added the next 2 lines for Acrobat 8.x - 1/29/2008 - CR24709 and WP25089
         Sheets("PLANT SUMMARY").Activate
         SaveToPDF ("C:\temp\Sheet" & Prints & ".pdf")
         pdDoc2.Open ("C:\temp\Sheet" & Prints & ".pdf")
         pdDoc2.SetInfo "Title", "PLANT SUMMARY"
         pdDoc2.Save 1, "C:\temp\Sheet" & Prints & ".pdf"
         pdDoc2.Close
        Prints = Prints + 1
    End If
    V_RPT = 1
    On Error Resume Next   'DO NOT REMOVE THIS LINE
    Do Until V_RPT > V_NBR_OF_RPTS
    v_sheet_name = V_RPT_ARRAY(V_RPT)
        Sheets(v_sheet_name).Activate
        Sheets(v_sheet_name).PageSetup.LeftFooter = Now()
        Sheets(v_sheet_name).PageSetup.CenterFooter = "#" & V_PLANT_NBR & " " & V_PLANT_NAME & Chr(13) & V_RPT_PERIOD
        'eob change start here--Change #9 comment out page numbers
        'Sheets(v_sheet_name).PageSetup.RightFooter = "Page " & Prints
        'eob change end
        AppendIni ("C:\temp\Sheet" & Prints & ".pdf")
        'Commented out next line for Acrobat 8.x - 1/29/2008 - CR24709 and WP25089
        'Sheets(V_SHEET_NAME).PrintOut
        'Added the next 2 lines for Acrobat 8.x - 1/29/2008 - CR24709 and WP25089
         If v_sheet_name = "EXPLANATION OF PLANT VARS" Then
           PageSetupFitToPageWidth
         End If
         SaveToPDF ("C:\temp\Sheet" & Prints & ".pdf")
         pdDoc2.Open ("C:\temp\Sheet" & Prints & ".pdf")
         pdDoc2.SetInfo "Title", v_sheet_name
         pdDoc2.Save 1, "C:\temp\Sheet" & Prints & ".pdf"
        Sheets(v_sheet_name).DisplayPageBreaks = False
        Prints = Prints + 1
        pdDoc2.Close
        V_RPT = V_RPT + 1
    Loop
    Kill ActiveWorkbook.Path & "\New Costbook.pdf"
    'Consolidate PDF Files
    On Error GoTo Err1
    pdfile = avDoc.Open("C:\temp\Sheet1.pdf", "Window Title")
    Set pdDoc1 = avDoc.GetPDDoc
    AcroApp.MenuItemExecute ("NewBookmark")
    pdtitle = PDBookmark.GetByTitle(pdDoc1, "Untitled")
    pdtitle = PDBookmark.SetTitle("Cover Sheet")
    pdDoc1.Save 1, ActiveWorkbook.Path & "\New Costbook.pdf"
    For z = 2 To Prints
        n = pdDoc1.GetNumPages()
        pdDoc2.Open ("C:\temp\Sheet" & z & ".pdf")
        If pdDoc2.GetNumPages() <> 0 Then
            pdDoc1.InsertPages n - 1, pdDoc2, 0, pdDoc2.GetNumPages(), False
            Set avPageView = avDoc.GetAVPageView()
            avPageView.GoTo (n)
            AcroApp.MenuItemExecute ("NewBookmark")
            pdtitle = PDBookmark.GetByTitle(pdDoc1, "Untitled")
            pdtitle = PDBookmark.SetTitle(pdDoc2.GetInfo("Title"))
            pdDoc2.Close
            pdDoc1.Save 1, "C:\temp\Sheet1.pdf"
        Else
            pdDoc2.Close
        End If
    Next z
    avPageView.GoTo (0)
    pdDoc1.SetPageMode (3)
    pdDoc1.Save 1, ActiveWorkbook.Path & "\New Costbook.pdf"
    pdDoc1.Close
    Set AcroApp = Nothing
    Set PDBookmark = Nothing
    Set avDoc = Nothing
    Set pdDoc1 = Nothing
    Set pdDoc2 = Nothing
    Application.ScreenUpdating = True
    Sheets("SYS - USER INTERFACE").Activate
    AppActivate "Microsoft Excel"
    MsgBox "File Saved As: " & ActiveWorkbook.Path & "\New Costbook.pdf", vbInformation
    Application.ActivePrinter = stdPrinter
    Kill "C:\temp\Sheet*.pdf"
    Exit Function
Err1:
    AppActivate "Microsoft Excel"
    MsgBox Err.Description
    Application.ActivePrinter = stdPrinter
End Function

Acrobat Scripting Forum http://forums.adobe.com/community/acrobat/acrobat_scripting
or more likely
Acrobat SDK Developer Forum http://forums.adobe.com/community/acrobat/acrobat_sdk

Similar Messages

  • Add bookmarks to pdf file using Excel VBA

    Good morning -
    I have, through internet searches, created an Excel macro that prints numerous workbooks to pdf, combines them into one file and prints that file.  I have been searching for the last piece, which is adding bookmarks, but have not had any luck getting any of it to work.  The following is the code that I am using to add the bookmarks -
    Dim avdoc, pddoc, app As Object
    Dim stFile As String
    Dim btitle As Boolean
    Dim PDBookmark As CAcroPDBookmark
    stFile = "D:\Test\Test.pdf"
    Set app = CreateObject("AcroExch.app")
    Set avdoc = CreateObject("AcroExch.AVDoc")
    Set pddoc = CreateObject("AcroExch.PDDoc")
    pddoc.Open stFile
    Set avdoc = pddoc.OpenAVDoc(stFile)
    Set PDBookmark = CreateObject("AcroExch.PDBookmark", "")
    app.MenuItemExecute ("NewBookmark")
    btitle = PDBookmark.SetTitle("Test Bookmark")
    This code does insert a bookmark on the first page of the document.  The bookmark title displays as Untitled instead of Test Bookmark as the code states.  Can someone answer the following questions -
    1.  Why is the code not changing the bookmark from Untitled to Test Bookmark, and
    2.  How would I nodify the above code to go to a certain page then enter the bookmark.
    All help is greatly appreciated.  Thanks in advance for your time.

    Good morning Reinhard -
    Thanks you very much for the help.  I implemented as follows:
    1.  app.MenuItemExecute ("NewBookmark")
    btitle = PDBookmark.GetByTitle(pddoc, "Untitled")
    btitle = PDBookmark.SetTitle("Total Accessories / Hardgoods")
    I added the "btitle =" due to it erroring out.  However, when I step through the code and get to that line, I get the "Excel has encountered an error and needs to close" error.  Is there a reference that I'm missing that you know of?
    2.  I was able to find the code to get to a specific page number and it is working great.
    Thanks again for all of your assistance.

  • Why are the options for "When Firefox starts" NOT clickable in Firefox 5? I want to choose "Windows and tabs that where opened last time you accessed the net" but Firefox won't let me.

    In the previous version of Firefox one could choose to save tabs so that when Firefox opened, all the tabs from the previous sessions appeared. This was done in Settings > Options > General > Startup. In the menu for the "When Firefox Starts" one had the option for "Windows and tabs that where opened last time you accessed the net." in Firefox 5.0, this menu is gray and not clickable. Help, please?

    ''Why are the options for "When Firefox starts" NOT clickable in Firefox 5?"
    Possibly you are not saving your "browsing history" which is what the session history is tied into.
    '''Not saving History''' -- check your settings for '''Tools > options > Privacy'''', make sure you are not clearing more than just cache in "Settings for Clearing History"
    * http://img232.imageshack.us/img232/4928/clearcachew.png
    * clearing your history at end of session, cache is the only one you would want to clear at end of session, if you don't want to lose things
    There are several things that are related to private browsing and not saving History
    * Private Browsing Ctrl+Shift+P
    * You selected "Never remember history" in first drop-down of Tools > Options Privacy and all of the check marks disappear (See picture above)
    * "Permanent private browsing mode" was check-marked under "Use custom settings for history" in the first drop-down of Tools > options > Privacy (see picture above)

  • Why are my notifications silent when I use my 4s on Toyota Fortuner bluetooth system, Why are my notifications silent when I use my 4s on Toyota Fortuner bluetooth system

    Why are my notifications silent when I connect my 4s to my Toyota Fortuner Bluetooth system ?

    Hi,
    The 'features' you refer to are not anything that a customer should really care about, so why don't you just turn them off.
    Do you really care about "Location-based iAds" - I've hardly ever even seen iAds!
    Do you really care about the time-zone updating based upon your international location - unless you are a very frequent traveller, this 'feature' is pretty useless and can be turned off without losing functionality that matters.
    The specific features to turn off are indicated in my post above - they are all in one place, they can all be turned off in about 20 seconds, and your problem will go away, and you will not lose any important functionality.
    Obviously I would agree with your point if you had to refrain from using the phone or making text messages, or playing games, or taking photos... all of which are genuinely useful features of a phone.
    But I disagree with you that you should deny yourself reasonable battery life on the basis that you need the specific features that made you buy this "Apple product and not an Android one" when these features are in fact not first-line, or even-second line features... they are just 'things' that make very little difference to how a person would use their iPhone at all.
    Anyway, that's my thoughts on it. Yes of course it would be great if Apple could fix the bug but as it isn't showstopping, I find it hard to get worked up about it

  • Why are two pages yoked when I prepare a newsletter in Pages?  How can I delete one without the other?

    Why are two pages yoked when I prepare a newletter?  How do I delete one without the other?

    They are all part of one Section. Just as you do not (hopefully) rip pages out at random from books, the pages of a Section are linked by the text that flows from one to the other.
    If you want to move or delete particular page/s Insert a Section Break at the end of the page before.
    Peter

  • HT3702 why are you charging me when i have not order any apps

    Why are you charging me when i have not order any apps

    Well I don't know. I just really, really, really wanted to test a legit versin of Angry Birds. Thought you wouldn't mind.
    But since you insist--
    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html

  • Why are my tags deleted when I replace pages?

    Why are my tags deleted when I replace pages?

    Hi Stephanie,
    My suggested workaround: In Acrobat Pro, in the Page Thumbnails pane, select the pages that you want to replace then right click and select "Delete pages". Then, right-click the page just ahead of where the replacement pages will go, select "Insert pages", and follow the prompts. This is just the way I do it, not the only way.
    Tiger26 is making the excellent suggestion that, prior to inserting pages, encapsulate the tags for the pages to be inserted using a Section tag. This makes the post-insertion chore of dragging the tags to their proper place in the tag structure easier.
    a 'C' student

  • Why are my styles disappearing when I cut and paste?

    Why are my styles disappearing when I cut and paste?

    Go to Preferences, and then into ClipboardHandling. Click a radio button choice for All Information instead of Text Only.

  • Why are my emails aborted when I'm trying to send pictures?

    Why are my emails aborted when im trying to send pictures?

    What is the size of the email attachments you are trying to send?  Many email providers limit the message content size some where in the 2-3 MB range, some larger some smaller.  If your photos are multile MBs that could cause the provider to reject the email.
    Try resaving a rejected photo to a smaller size/resolution and see if it goes successfully.

  • Why I still can't transfer PDF doc to Excel or Word formats after I had purchased annual subscription as instructed?  I had paid via Apple Store, with my iphone5s!

    Why I still can't transfer PDF doc to Excel or Word formats after I had purchased annual subscription as instructed?  I had paid via Apple Store, with my iphone5s!

    Dear Sara,
    I was been asked to subscribe to the
    service on my App after I
    had subscribed already?
    I have also try to log in to
    Acrobat.com, but nothing came up after I clipped Sign in?
    Regards,
    James Chu
    在 2014年5月12日,22:10,"Sara.Forsberg" <[email protected]> 写道:
    Why I still can't transfer PDF doc to Excel or Word formats after I had purchased annual subscription as instructed?  I had paid via Apple Store, with my iphone5s!
    created by Sara.Forsberg in Adobe ExportPDF - View the full discussion
    Hi cyberjames,
    Do you get an error message when you try to export your file? Or, are you continually asked to subscribe when you try to convert a link? If it's the latter, it could be that you just haven't signed in to the app yet. Try this:
    From the ExportPDF website, click Sign in at the upper-right corner, and log in to the service with your Adobe ID credentials. Now, when you click ExportPDF, you'll be prompted to select PDF files to export, instead of being asked to subscribe.
    If you're receiving an error message when you try to log in, let us know what it is, and we can go from there.
    Best,
    Sara
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6375306#6375306
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Adobe ExportPDF by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • PDF created using Java iText package - Text not editable and not displaying font properties on Acrobat

    Hi,
    I have an issue in editing the text and viewing the font properties of a text region on a PDF created using Java iText package.
    I use Adobe Acrobat 9 Pro Extended and the option Tools -> Advanced Editing -> TouchUp Text Tool.
    The strange behaviour is that, I have 2 PDFs created out of the same base PDF and text added via Java iText package with the same Text, Font and other properties.
    One of the PDF has the text region editable on Acrobat but the other one has the text region which is not editable.
    But both the PDFs are editable via Adobe Illustrator.
    I have attached both the PDFs for your reference
    PDF_Editable.pdf - Editable on Acrobat
    PDF_Not Editable.pdf - Not Editable on Acrobat
    Any help or insight to find out the difference/issue with the PDF which is not editable via Acrobat would be appreciated.
    Thanks in advance.
    Regards,
    Madhusoodhan Henryraman

    You don't have direct control of the leading of a multiline text field. A common approach is to control the background color of the field with JavaScript since the lines are not really needed when the field is used in Reader/Acrobat. They may be useful when using the form by hand. For more information, see the posts by Max in this topic: http://acrobatusers.com/forum/forms-acrobat/how-do-i-use-multi-lined-text-fields-over-prin ted-line-area-existing-form

  • Why can't I download a pdf file using internet explorer as my browser.I can download pdfs using fire

    Why can't I download a pdf file using internet explorer as my browser. I can download pdfs using firefox.

    Gilad D,
    Thanks for the support.
    I would guess the plugin is enabled since when I use Foxfire as my browser, all pdfs download and are readable. (just doesn’t happen when I use IE as my browser, I get a blank screen with a small “x” in the upper left corner)
    I will try your proposed solution.
    Charlie

  • Are the fonts that are available to me when I am using the free trial of InDesign less than when I use the purchased version of InDesign?

    Are the fonts that are available to me when I am using the free trial of InDesign less than when I use the purchased version of InDesign?

    Try to find out: When you install the Creative Cloud Desktop app, Click Assets, then click Fonts. Click Add Fonts from Typekit. If you can do that, you're in. Of course, you won't be able to use them more than 30 days unless you subscribe. (But fonts embedded in a PDF or EPUB file would be fine.)
    Those of us who are CC subscribers cannot test this out easily.

  • HT1665 Why are my contacts not listed ?  They used to be there.

    Why are my contacts not listed?  They used to be there.

    I had the same thing happen to me.  It's a bug in iPhoto 9.4.2.
    The first time you run iPhoto after upgrading to iPhoto 9.4.2, it "updates the iPhoto library".  This sometimes tickles a bug where iTunes can see all your iPhoto albums, but iTunes thinks they are empty.  Since iTunes thinks all your albums are empty, it dutifully deletes any photos from your synced iOS devices.
    It's easy to tell if this is the problem you are seeing.  Open iTunes and go to the photos sync panel for one of your iOS devices.  If you have multiple albums checked, but iTunes shows a total of 0 photos, then you have the problem.
    I spent an hour with an Apple Genius.  he couldn't find any mention of this problem in their internal support system.  His recomendation was to reinstall the operating the system.  I suspect that this won't solve it.
    The only solution I have found is to restore iPhoto 9.4.1 and the corresponding iPhoto library from your backups.
    I would refrain from upgrading to iPhoto 9.4.2 until Apple has a fix for this issue.

  • Copying Graphs and Pie Charts generated in Analysis View to Email item using Excel VBA Macro Code

    Hi
    I am currently working on an exce VBA macro code that would help me take snapshots of the Graphs and Pie charts generated in QC for a particular application and copy the same to an email item using excel VBA macro code.
    I was able to write the code to create an email item. But I have no clue of how i can take snapshot of the graphs in Analysis View using excel VBA
    Any help would be highly appreciated.
    Thanks in Advance
    Regards
    Amit

    useramit,
    You are in the consumer end products forum.  You will also want to ask your question over at the Enterprise Business Community.
    Click the plus sign (+) next to Discussion Boards to drop down all the options for servers, networking and any other professionally related problems.
    http://h30499.www3.hp.com/

Maybe you are looking for

  • Threading in ABAP?

    I have a scenario (Order taking) where the execution logic takes considerable time to finish the processing. As a result, the end user who is using the web application has to wait for at-least 10 minutes till the processing is complete. In the UI (We

  • My BT Vision details not showing in My Products

    I upgraded from the old unlimited TV package to the new entertainment package with Sky Movies this was in October. Since this product change the BT Vision details section is blanked out, with a error message "we can't find your TV plan details view y

  • Example for FAGL_GET_OPEN_ITEMS_GL

    Hi All, I wanted to use the FM FAGL_GET_OPEN_ITEMS_GL Can any one tell me what are the parameters value  to pass for this function module. Please Explain this with Example. Thanks.

  • Can I change the text-quoting "pipe" to another character?

    The 'pipe' makes it hard for me to format quoted text, so I want to change it to the good ol' greater-than sign. I've read that a recipient will see the greater-than sign in their message, but I want to see it on my screen when composing a reply. Tha

  • Error when connecting not resolved by restore

    My iPod touch connects to iTunes and syncs everything it needs to, but I get the error message "The iPod '(name)' cannot be synced. An unknown error occured (-50)." I tried to restore it from a backup but that did not resolve the issue. This error be