Bookmark pages using Excel VBA

Please help me writing a VBA script to bookmark all pages having a common word  in a document.
I am alraedy done with:
opening a document
Finding the word
Placing a book mark
Challenge is I want bookmark placed on all pages where word "customer" appears. My current code only put bookmark on first result after finding "customer"
Kindly help this is extremely urgent.

If you have that code, you should just continue it
Find next string
Have we bookmarked this page?
If not, add bookmark
Loop until no more strings

Similar Messages

  • 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/

  • How to Select Members Based on Attributes using Excel VBA

    Hi there,Does anyone know how to select members based on attributes using Excel VBA?I don't seem to be able to find macros or functions to do that.Panda

    you can use the Range or the Cells objects to get a reference to your range values
    in this sample the data is on A1 to B5
    Dim lineList(4)
    lineList(0) = Array(Cells(1, 1).Value, Cells(1, 2).Value)
    lineList(1) = Array(Cells(2, 1).Value, Cells(2, 2).Value)
    lineList(2) = Array(Cells(3, 1).Value, Cells(3, 2).Value)
    lineList(3) = Array(Cells(4, 1).Value, Cells(4, 2).Value)
    lineList(4) = Array(Cells(5, 1).Value, Cells(5, 2).Value)

  • Using Excel VBA to save PDF file as a text (plain) file?

    I'm using 8.0 Acrobat Pro.
    Third party apps are not an option (I'm restricted from installing anything on my office PC).
    I could simply save each PDF manually, but given the number of files this would not be practical.
    The text it will output does not have to be pretty by any means (and I'm aware it won't be).
    As long as I can get the PDF files in a text file format, there would be no further obstacles for me - because I would then be able to get Excel to gather-import all the data and consolidate-clean-organize everything accordingly at that point.
    What's in these PDF files are simply names, numbers, and email addresses (basic office text type data stuff simple).
    I wish to save them all as text files, and then use Excel to suck all the data from those newly created text files and consolidate-organize them accordingly.
    The VBA module I've seen referrenced around the web is the following beneath; however, I am having no luck with it.
    I keep getting the error message:
    ActiveX component can't create object or  return reference to this object (Error 429)
    I am running Microsoft Office 2010 | Excel (and using Adobe Acrobat Pro 8.0).
    Any help is extremely appreciated.
    Here is the VB code in Excel I'm having trouble with:  What this is supposed to do is simply find the specified PDF file and save it as a Plain Txt File.
    Sub Convert_PDF_To_Text_File()
    Dim AcroXApp As Object
    Dim AcroXAVDoc As Object
    Dim AcroXPDDoc As Object
    Set AcroXApp = CreateObject("AcroExch.App")
    AcroXApp.Hide
    Set AcroXAVDoc = CreateObject("AcroExch.AVDoc")
    AcroXAVDoc.Open strPDFPath, "Acrobat"
    AcroXAVDoc.BringToFront
    Set AcroXPDDoc = AcroXAVDoc.GetPDDoc
    Dim jsObj As Object
    Set jsObj = AcroXPDDoc.GetJSObject
    jsObj.SaveAs strOutputFile, "com.adobe.acrobat.plain-text"
    AcroXAVDoc.Close False
    AcroXApp.Exit
    End Sub

    one other thought is that you can create text files with a batch process inside of acrobat.  Advanced ---> Document Processing ----> Batch Processing.
    Choose new sequence, give it a name
    Step 1: Select Commands ----> Choose "execute javascript", then hit "Add."  Click on "Execute Javascript" that was just added on the right, then hit the edit button and toss in the script below that I grabbed from the javascript samples (also, if your docs have multiple pages you'll need to embed the for loop into another for loop that cycles through each page).  You'd also want to change the name of the saved txt file to the name of pdf you're doing it to.  It shouldn't be that hard, but I'm guessing you're probably alot more familiar with VBA then javascript which is why you're choosing to do it from excel.  I'm kind of in the same boat of having written a bunch of VBA, but not much javascript.  I highly recommend investing some time into learning acrobat scripting b/c VB does have it's limitations when it comes to messing with PDF's.
    * function to extract the text content of the current page and save to a file.
    try  {
    var p = this.pageNum;
    var n = this.getPageNumWords(p);
    app.alert("Number of words in the page: " + n);
    var str = "";
    for(var i=0;i<n;i++) {
    var wd = this.getPageNthWord(p, i, false);  
    if(wd != "") str = str + wd;  
    // save the string into a data object
    this.createDataObject("whatever.txt",str); 
    // pop up a file selection box to export the data
    this.exportDataObject("whatever.txt");
    // clean up
    this.removeDataObject("whatever.txt");
    } catch (e)  { 
    app.alert(e)

  • Using Excel VBA to Print to PDF File?

    Hi, All !!
    I have an Excel VBA application that creates Excel reports.  These need to be sent external to our company in PDF format.  I've downloaded the Acrobat SDK and have found the VB sample for AdobePDFSilent.  Unfortunately, it appears that this is written for VB or VB.Net as I don't have any of the data types available that are created in the code.  However, from another forum, I've gotten some VB code that appears to do many of the processes included in the SDK sample.
    The code below doesn't give me any errors, but no PDF file is created.
    My VBA code
    Declare Function RegOpenKeyA Lib "advapi32.dll" ( _
        ByVal Key As Long, _
        ByVal SubKey As String, _
        NewKey As Long) As Long
    Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" ( _
        ByVal hKey As Long, _
        ByVal lpValueName As String, _
        ByVal Reserved As Long, _
        ByVal dwType As Long, _
        lpData As Any, _
        ByVal cbData As Long) As Long
    Declare Function RegCloseKey Lib "advapi32.dll" ( _
        ByVal hKey As Long) As Long
    Sub TestPrintPDF()
        Dim strDefaultPrinter As String
        Dim strOutFile As String
        Dim lngRegResult As Long
        Dim lngResult As Long
        Dim dhcHKeyCurrentUser As Long
        Dim PDFPath As String
        Const dhcRegSz As Long = 1
    1    Workbooks.Open ("\\master\fnshares\bcbcm\Client Management\Client Services\New Account Fees\09 September 2010\3Q10 Rebate Ltrs\Infi\MacroTest\A02.xls")
    2    Select Case ActiveWorkbook.Sheets.Count
    3        Case 1
    4            Sheets(1).Select
    5        Case 2
    6            Sheets(Array(Sheets(1).Name, Sheets(2).Name)).Select
    7        Case 3
    8            Sheets(Array(Sheets(1).Name, Sheets(2).Name, Sheets(3).Name)).Select
    9        Case 4
    10            Sheets(Array(Sheets(1).Name, Sheets(2).Name, Sheets(3).Name, Sheets(4).Name)).Select
    11        Case 5
    12           Sheets(Array(Sheets(1).Name, Sheets(2).Name, Sheets(3).Name, Sheets(4).Name, Sheets(5).Name)).Select
    13      Case 6
    14         Sheets(Array(Sheets(1).Name, Sheets(2).Name, Sheets(3).Name, Sheets(4).Name, Sheets(5).Name, Sheets(6).Name)).Select
    15  End Select
    16  dhcHKeyCurrentUser = &H80000001
    17  strDefaultPrinter = Application.ActivePrinter
    18  PDFPath = ActiveWorkbook.Path & Application.PathSeparator 'The directory in which you want to save the file
    19  strOutFile = PDFPath & Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & ".pdf" 'Change the pdf file name if required. This should have the fully qualified path
    20  lngRegResult = RegOpenKeyA(dhcHKeyCurrentUser, "Software\Adobe\Acrobat Distiller\PrinterJobControl", lngResult)
    21  lngRegResult = RegSetValueEx(lngResult, Application.Path & "\Excel.exe", 0&, dhcRegSz, ByVal strOutFile, Len(strOutFile))
    22  lngRegResult = RegCloseKey(lngResult)
    23  ThisWorkbook.ActiveSheet.PrintOut copies:=1, ActivePrinter:="Adobe PDF"
    24  Application.ActivePrinter = strDefaultPrinter
    25  ActiveWorkbook.Close False
    End Sub
    From what I can determine, the lines 17 & 24 combined basically accomplish the same thing as the SaveandUpdateDefaultPrinter function in the SDK (get and save the current default printer and return it to that default after printing the PDF).
    Line 20 opens the Registry key for Distiller\PrinterJobControl which is done in part of the ConvertFile function in the following SDK code.
    SDK Code
                Dim objDistillerRegKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.ClassesRoot
                Dim strDistillerSubKey As String = "SOFTWARE\\Adobe\\Acrobat Distiller\\PrinterJobControl"
                'Open Current User's Distiller Subkey for writing
                objDistillerRegKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(strDistillerSubKey, True)
    Line 21 sets the Registry key for Excel with the name of the PDF file to output which also appears to be done in part of the ConvertFile function in the following code.
    SDK Code
               If (Not objDistillerRegKey Is Nothing) Then     'set reg key value for this app and file
                    objDistillerRegKey.SetValue(strAppPath, strOutputFile)
                    objDistillerRegKey.Close()
                End If
    I have verified, using RegEdit, that this Registry key does get set with the desired output filename.
    Line 23 prints the Excel file to PDF when done manually (this was recorded using the Excel Macro Recorder).  This should be comparable to the PrintToAdobePDF function in the SDK as below.
    SDK Code
        Private Sub PrintToAdobePDF(ByVal InputfilePath As String)
            'Prints InputFilePath to the AdobePDF printer.
            'Since we just gathered all this info programmatically,
            'this function assumes the file is present, that it has an
            'associated application and that the current user has print privileges.
            'Define properties for the print process
            Dim pProcInfo As New ProcessStartInfo
            pProcInfo.FileName = InputfilePath
            pProcInfo.Verb = "Print"
            'Make process invisible
            pProcInfo.CreateNoWindow = True
            pProcInfo.WindowStyle = ProcessWindowStyle.Hidden
            'start print process
            Dim pMyProc As Process = Process.Start(pProcInfo)
            pMyProc.WaitForExit()
        End Sub
    These are some of the statements I can't do because I don't have a ProcessStartInfo type.  What am I doing wrong or NOT doing that the PDF file is not created?  I hope I've described my situation in enough, but not too much detail.  Thanks for your help.
    Nate Brei

    Reinhard & Karl Heinz,
    Thank you both for your responses and willingness to work with me on this problem.  This is driving me crazy & is getting very frustrating.  It seems that I've tried everything that people have suggested (I've also posted on a VB Forum that I subscribe to) and I'm basically doing what works for everyone else but doesn't work for me.  I've got to be close.
    Reinhard, regarding your last post, it doesn't appear to be a one-time setting.  Everytime I come into the Printers Property box (even after I've printed a PDF document manually, that option about system & document fonts is ALWAYS turned on.  If it is a registry setting, please let me know how to turn it off.  I'm using Adobe Acrobat 9 Standard.
    Karl Heinz, I've tried that based on my initial post (see the code there).  Since your post, I tried it again.  I get the same result, NO FILE is produced anywhere.
    I wish I could post pictures, but evidently I can't.  So, I going to post first my code (in case you want to try to recreate my problem), then the values of the variables in that code when I run it (so you can I have everything set correctly as far as I know), and finally, the values of the Registry entries that I have after I run it.  So, please bear with me as the post may be a little long.
    My Code
    Declare Function RegOpenKeyA Lib "advapi32.dll" ( _
        ByVal Key As Long, _
        ByVal SubKey As String, _
        NewKey As Long) As Long
    Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" ( _
        ByVal hKey As Long, _
        ByVal lpValueName As String, _
        ByVal Reserved As Long, _
        ByVal dwType As Long, _
        lpData As Any, _
        ByVal cbData As Long) As Long
    Declare Function RegCloseKey Lib "advapi32.dll" ( _
        ByVal hKey As Long) As Long
    Sub TestPrintPDF()
        Dim strDefaultPrinter As String
        Dim strOutFile As String
        Dim lngRegResult As Long
        Dim lngResult As Long
        Dim dhcHKeyCurrentUser As Long
        Dim PDFPath As String
        Const dhcRegSz As Long = 1
        'Workbooks.Open ("\\master\fnshares\bcbcm\Client Management\Client Services\New Account Fees\09 September 2010\3Q10 Rebate Ltrs\Infi\MacroTest\A02.xls")
        Workbooks.Open ("H:\A02.xls")
        Select Case ActiveWorkbook.Sheets.Count
            Case 1
                Sheets(1).Select
            Case 2
                Sheets(Array(Sheets(1).Name, Sheets(2).Name)).Select
            Case 3
                Sheets(Array(Sheets(1).Name, Sheets(2).Name, Sheets(3).Name)).Select
            Case 4
                Sheets(Array(Sheets(1).Name, Sheets(2).Name, Sheets(3).Name, _
                 Sheets(4).Name)).Select
            Case 5
                Sheets(Array(Sheets(1).Name, Sheets(2).Name, Sheets(3).Name, _
                 Sheets(4).Name, Sheets(5).Name)).Select
            Case 6
                Sheets(Array(Sheets(1).Name, Sheets(2).Name, Sheets(3).Name, _
                 Sheets(4).Name, Sheets(5).Name, Sheets(6).Name)).Select
        End Select
        dhcHKeyCurrentUser = &H80000001
        strDefaultPrinter = Application.ActivePrinter
        'The directory in which you want to save the file
        PDFPath = ActiveWorkbook.Path & Application.PathSeparator
        'Change the pdf file name if required. This should have the fully qualified path
        strOutFile = PDFPath & Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & ".pdf"
        lngRegResult = RegOpenKeyA(dhcHKeyCurrentUser, "Software\Adobe\Acrobat Distiller\PrinterJobControl", _
            lngResult)
        lngRegResult = RegSetValueEx(lngResult, Application.Path & "\Excel.exe", 0&, dhcRegSz, _
            ByVal strOutFile, Len(strOutFile))
        lngRegResult = RegCloseKey(lngResult)
        ThisWorkbook.ActiveSheet.PrintOut copies:=1, ActivePrinter:="Adobe PDF"
        'ThisWorkbook.ActiveSheet.PrintOut copies:=1, preview:=False, ActivePrinter:="Adobe PDF", _
            printtofile:=True, collate:=True, prtofilename:=strOutFile
        'Call printToPdf(strOutFile)
        Application.ActivePrinter = strDefaultPrinter
        ActiveWorkbook.Close False
    End Sub
    Sub printToPdf(PDFFilename)
        ' Define a postscript file name
        PSFileName = "H:\TempPostScript.ps"
        ' Print the Excel range to the postscript file
        'Dim MySheet As Worksheet
        'Set MySheet = ActiveSheet
        ActiveWindow.SelectedSheets.PrintOut copies:=1, preview:=False, ActivePrinter:="Adobe PDF", _
            printtofile:=True, collate:=True, prtofilename:=PSFileName
        ' Convert the postscript file to .pdf
        Set myPDF = CreateObject("PdfDistiller.PdfDistiller.1")
        myPDF.FileToPDF PSFileName, PDFFilename, ""
    End Sub
    Values of my Variables When I Run the Code
    ? dhcHKeyCurrentUser
         -2147483647
    ? strDefaultPrinter
         \\tcps01p\FNT12W00 Canon 5020 PCL 5e on Ne04:
    ? PDFPath
         H:\
    ? strOutFile
         H:\A02.pdf
    ? lngResult
         2280
    ? Application.Path & "\Excel.exe
         C:\Program Files\Microsoft Office\OFFICE11\Excel.exe
    ? dhcRegSz
         1
    ? Len(strOutFile)
         10
    ? PSFileName
         H:\TempPostScript.ps
    ? PDFFilename
         H:\A02.pdf
    Values of my Registry Entries (HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\PrinterJobControl)
    (Default)          REG_SZ          (value not set)
    C:\Program Files\Microsoft Office\OFFICE11\Excel.exe          REG_SZ          H:\A02.pdf
    LastPdfPortFolder - EXCEL.EXE          REG_SZ          "Q:\Client Management\Client Services\New Account Fees\09 September 2010\3Q10 Rebate Ltrs\Infi\MacroTest
    Note:  There are a couple of other entries for documents that I've printed manually that I didn't include.  Also, the last entry above, contains the value of the folder that I last manually "printed" to.
    I've also noticed that I have a Registry SubKey under PrinterJobControl called DownloadFonts.  However, the only entry there is:
         (Default) REG_SZ (value not set)
    Is this the registry key you mentioned, Reinhard?
    As you can see in my code, I have 3 different methods that I've tried to print.  The first one defaults everything after selecting the Acrobat PDF printer.  The second sets the output filename as a PDF (basically what you suggested, Karl Heinz).  The third method calls a procedure that prints to a PostScript file & then uses Distiller to print from that file to pdf.  This is the method Reinhard suggested.
    With the first 2 methods, I get NO error messages, but no file(s) show up.  With the 3 method, I get the error about the Fonts checkbox, but it creates a 0K PostScript file.  When I skip that statement and run the other 2 statements, I get a log file that says the PostScript file is empty and not PDF file was created.
    YIKES...  What's going on?  Thanks again for attempting to help me!!!
    Nate

  • How to set task type of a task in MS Project using excel vba code.

    Hello Gurus,
    I am generating MS Project files(.mpp) files form excel data. An excel macro in the excel file will read the excel data and will generate the .mpp file. It is working fine. now i want to set the task type of all the tasks to "Fixed work" from excel
    vba code.
    How to use the property PjTaskFixedType in setting the task type??
    refer below links
    http://msdn.microsoft.com/en-us/library/office/ff861713.aspx
    http://msdn.microsoft.com/en-us/library/office/ff864157.aspx
    Can someone help me in setting task type property from excel vba.
    I have attached my sample code used to generate the mpp file. It is not the complete code but you will get an idea from it.
    Set pjApp = CreateObject("MSProject.Application")
    pjApp.FileNew
    Set newproj = pjApp.ActiveProject
    newproj.Tasks.Add (task_name)
    newproj.Tasks(mpp_row_number).Start = task_start_date
    newproj.Tasks(mpp_row_number).Finish = task_end_date
    newproj.Tasks(mpp_row_number).ResourceNames = resource_name
    pjApp.FileSaveAs mpp_file_save_path & mpp_file_name & ".mpp"
    pjApp.FileClose
    pjApp.Quit
    Any help is appreciated.

    Hi Syamku,
    A simple example that sets the task type:
    ActiveProject.Tasks(2).Type = pjFixedDuration
    ActiveProject.Tasks(3).Type = pjFixedUnits
    ActiveProject.Tasks(4).Type = pjFixedWork
    http://msdn.microsoft.com/en-us/library/office/ff860469(v=office.15).aspx
    Hope this helps

  • How to change the status of test cases in Test Plan from Design to Ready using Excel VBA

    HI,
    How to change the status of test cases in Test Plan from Design to Ready using Excel VBA

    Thanks Florin,
    Your piece of code has worked alot, and it was very helpful in changing the Status of the Workitem to "READY" for all the Users fo the workitem.
    Points have been rewarded for your help.
    Process: We have acheived this using the "Work Item Exits", Usng "AFTER_EXECUTION" Method.
    Note: The Exit will be executed if "exit_cancelled"  statement is present/used in the work item method. if not it is not taking to the exit code. I'm unable to find the reason for it. Florin can u please explain this point.
    Please check the link for adding the code in Work Item Exits.
    http://wiki.sdn.sap.com/wiki/display/ABAP/ProgramExitsIn+Workflow
    Please find the Code:
    method IF_SWF_IFS_WORKITEM_EXIT~EVENT_RAISED.
    Get the context of the workitem
      me->wi_context = im_workitem_context.
    After execution of the workitem call the method AFTER_EXECUTION
      if im_event_name eq swrco_event_after_execution.
        me->after_execution( ).
      endif.
    endmethod.
    METHOD AFTER_EXECUTION.
    This method acts as the Event Handler for SWRCO_EVENT_AFTER_EXECUTION
      DATA: LCL_L_WID TYPE SWW_WIID,
            L_STATUS TYPE SWR_WISTAT-STATUS,
            L_NEW_STATUS  TYPE SWR_WISTAT,
            L_SWR_MESSAG  TYPE STANDARD TABLE OF SWR_MESSAG,
            L_SWR_MSTRUC  TYPE STANDARD TABLE OF SWR_MSTRUC.
    Get work item
      CALL METHOD WI_CONTEXT->GET_WORKITEM_ID
        RECEIVING
          RE_WORKITEM = LCL_L_WID.
      L_STATUS = 'READY'.
      CALL FUNCTION 'SAP_WAPI_SET_WORKITEM_STATUS'
        EXPORTING
          WORKITEM_ID    = LCL_L_WID
          STATUS         = L_STATUS
          USER           = SY-UNAME
          LANGUAGE       = SY-LANGU
          DO_COMMIT      = 'X'
        IMPORTING
          NEW_STATUS     = L_NEW_STATUS
         RETURN_CODE    = SY-SUBRC
        TABLES
          MESSAGE_LINES  = L_SWR_MESSAG
          MESSAGE_STRUCT = L_SWR_MSTRUC.
      IF SY-SUBRC EQ 0.
      ENDIF.
    ENDMETHOD.
    Thank You Once Again,
    Ajay Kumar Chippa

  • 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 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

  • Is it possible to automate Firefox using Excel VBA

    We have done automating Internet explorer using VBA, Now we have few projects which supports and do working on Mozilla only , ..so need to automate the applications in firefox using VBA excel macros .
    I heard it is possible by adding and regestring some dll's. So Could you please help me on this with details.
    Thanks & Regards,
    Nani.

    This forum is for '''user''' support, your question is beyond the scope of user support.
    Try searching the Mozilla Developer Network website about your query. <br />https://developer.mozilla.org/en-US/ <br />
    Here's an article about building a component DLL. <br />
    https://developer.mozilla.org/en-US/docs/Building_a_component_DLL

  • How to download data using excel vba.

    I'm trying to download data from web sites to excel using VBA.  I've found a bunch of resources like this one on stackoverflow, but they all refer to excel being run on windows.
    Does anyone know how to either scrape data or to use an API to pull data into excel?

    for exemple using
    MS_EXCEL_OLE_STANDARD_DAT

  • Using Excel VBA to Programmatically change Adobe Print Properties

    Did the Registry location of the "Rely on system fonts, do not use document fonts" setting change for Acrobat 10? It is not located in the Registry location mentioned in this discussion:
    http://forums.adobe.com/thread/422928
    Any Ideas?
    Much appreciated.

    Did the Registry location of the "Rely on system fonts, do not use document fonts" setting change for Acrobat 10? It is not located in the Registry location mentioned in this discussion:
    http://forums.adobe.com/thread/422928
    Any Ideas?
    Much appreciated.

  • Error in Excel VBA script while using sharepoint web service

    Hi Can you please help me out  in this ?
    nain1987

    Hi Nain,
    According to your description, my understanding is that the error occurred in the Excel VBA scripts which was used to update SharePoint list.
    I recommend to check if the URL of the web service is in the right scope. If the list is in a subsite, the URL should be: http://servername/site/ _vti_bin/Lists.asmx.
    To update SharePoint list using Excel VBA script, you can refer to the link below:
    http://sharepoint.stackexchange.com/questions/34433/update-sharepoint-list-using-excel
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Return String from Oracle stored proc using Excel 2003 VBA

    Hi to everyone,
    I've got a problem that remains unsolved for many days. I am trying to return a value of an oracle stored procedure using Excel VBA. It might seem trivial, however it's not for someone, who has never done it before...
    OS: Win XP SP3
    Excel 2003
    Ora Client: 11g
    By trying different things I have noticed, that I could have troubles with the ODBC-connection. Maybe I am not using the right one. To store data returned from select statements I have an ODBC-Connection (Driver: Oracle in XE), which works perfectly, e.g.:
    Sub Extract_Data()
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim db_name, UserName, Password As String
    cn.Open db_name, USerName, Password
    sql_statement = "SELECT some_text FROM some_table"
    Set rs = cn.Execute(sql_statement)
    rs.MoveFirst 'jump to the first entry in the data list
    Row = 2
    While Not rs.EOF
    'save the data to a worksheet
    ip.Cells(Row, 2) = rs(0).Value
    Row = Row + 1
    rs.MoveNext
    Wend
    End Sub
    Now I need to execute a stored procedure to return a semi-colon delimited string.
    I have tried the following:
    Public Sub obj_class()
    Dim cn As New ADODB.Connection
    Dim strSQL, cn As String
    Dim adoCMD As ADODB.Command
    Dim adoRS As ADODB.Recordset
    Set wb = Excel.ActiveWorkbook
    Set ih = wb.Sheets("InfoSheet")
    cn.Open db_name, UserName, Password
    Set adoCMD = New ADODB.Command
    With adoCMD
    .ActiveConnection = cn
    .CommandText = "S#mdb$stg_da_extr_util.get_all_classes_of_classif"
    .CommandType = adCmdStoredProc
    .Parameters.Refresh
    '------ and here comes the error saying:
    '------ could not find the object in the collection corresponding to the name or ordinal reference requested by the application
    .Parameters("i_caller").Value = "'STG_DATA_REQUEST'"
    .Parameters("i_obj_classif_id").Value = 120
    Set adoRS = .Execute()
    End With
    End Sub
    I did asked on the forum:
    http://www.access-programmers.co.uk/forums/showthread.php?p=1241667#post1241667
    but unfortunately without success.
    Could it be, that my ODBC-connection is wrong? When debugging the connection string, I find the Provider=MSDASQL5.1.
    I have moderate knowledge in VBA, but absolutely a newbie with Oracle DB. Is there any source of information that can help solving this issue? Looking forward to hearing from you, as I am almost giving up... ;(

    My VBA is super rusty. Does that error come after Parameters.Refresh, or after .Parameters("i_caller").Value = "'STG_DATA_REQUEST'"?
    If it's the second one, you'll need the definition of the stored procedure so you can see what parameters it's expecting. That'd mean you're getting something wrong with the names.

  • CALL RFC DATA FROM TWO LINKED TABLES IN EXCEL VBA

    Hi,
    I am using Excel VBA to call information from tables in SAP.
    This is working correctly, however I now need to be able to call information from another table where the two tables are linked by a common data field.
    Example.
    The first table I have lists all items in stock and contains an article number. The second table contains all article numbers and their descriptions.
    I want to be able to call the first table but to have the article codes description on there aswell.
    Here is the code I am currently using.
    Sub GetTable()
    'Connect to SAP
    Dim sapConn As Object 'Declare variant
    Set sapConn = CreateObject("SAP.Functions") 'Create ActiveX object
    sapConn.Connection.System = "QA2"
    sapConn.Connection.client = "900"
    sapConn.Connection.user = "mbrough"
    sapConn.Connection.Password = "st34lh"
    sapConn.Connection.Language = "EN"
    If sapConn.Connection.Logon(1, False) <> True Then 'Try Logon
       MsgBox "Cannot Log on to SAP"
    End If
    'Define the table specifics
    Dim objRfcFunc As Object
    Set objRfcFunc = sapConn.Add("RFC_READ_TABLE")
    Dim objQueryTab, objRowCount As Object
    Set objQueryTab = objRfcFunc.Exports("QUERY_TABLE")
    objQueryTab.Value = "LQUA"
    Set objRowCount = objRfcFunc.Exports("ROWCOUNT")
    objRowCount.Value = "15000"
    Dim objOptTab, objFldTab, objDatTab As Object
    Set objOptTab = objRfcFunc.Tables("OPTIONS")
    Set objFldTab = objRfcFunc.Tables("FIELDS")
    Set objDatTab = objRfcFunc.Tables("DATA")
    'Set the condition and refresh the table
    objOptTab.FreeTable
    objOptTab.Rows.Add
    objOptTab(objOptTab.RowCount, "TEXT") = "LGTYP BETWEEN 'K01' AND 'K06'"
    'Set fields to obtain and refresh table
    objFldTab.FreeTable
    'Then set values to call
    objFldTab.Rows.Add
    objFldTab(objFldTab.RowCount, "FIELDNAME") = "LGNUM"
    objFldTab.Rows.Add
    objFldTab(objFldTab.RowCount, "FIELDNAME") = "MATNR"
    objFldTab.Rows.Add
    objFldTab(objFldTab.RowCount, "FIELDNAME") = "WERKS"
    objFldTab.Rows.Add
    objFldTab(objFldTab.RowCount, "FIELDNAME") = "LGTYP"
    objFldTab.Rows.Add
    objFldTab(objFldTab.RowCount, "FIELDNAME") = "LGPLA"
    objFldTab.Rows.Add
    objFldTab(objFldTab.RowCount, "FIELDNAME") = "GESME"
    objFldTab.Rows.Add
    objFldTab(objFldTab.RowCount, "FIELDNAME") = "VERME"
    objFldTab.Rows.Add
    objFldTab(objFldTab.RowCount, "FIELDNAME") = "MEINS"
    If objRfcFunc.Call = False Then
       MsgBox objRfcFunc.Exception
    End If
    Dim objDatRec As Object
    Dim objFldRec As Object
    For Each objDatRec In objDatTab.Rows
       For Each objFldRec In objFldTab.Rows
          Cells(objDatRec.Index, objFldRec.Index) = _
                Mid(objDatRec("WA"), objFldRec("OFFSET") + 1, objFldRec("LENGTH"))
       Next
    Next
    End Sub
    The table which contains the article descriptions is called 'MAKT' and this table also contains the column 'MATNR' which is the article field.
    Many thanks,
    Mike

    Is there no way of connecting the tables within the code.
    IT won't give me access to SE11
    Thanks,
    Mike

Maybe you are looking for