How to merge 4 files with VBA

I have 4 files that I want to automatically merge using Visual Basic for Applications Code. I've searched through this forum and it seems that first you open the first pdf with PDDoc and then you use PDDoc.InsertPages to add the 2nd PDF and so on. Note these 4 files are each one page long. I am using Adobe Acrobat Professional and no this is not a server based application that I am developing. I am not interested in Adobe Live Cycle Designer. I am having difficulty inserting the page. I do not know how to define/specify the iPDDocSource As Object. The code I have written so far is below. Note eventually I want this to be invisible (ie PDDoc), but being able to perform using AVDoc could also be useful. Thanks.
Dim Path As String, Path1 As String, Path2 As String
Dim Path3 As String, Path4 As String
Dim gApp As Acrobat.AcroApp
Dim gPDDoc As Acrobat.AcroPDDoc
Dim iPDDocSource As Acrobat.AcroPDDoc
Dim jso As Object
Dim gAVDoc As Acrobat.AcroAVDoc
Path = "C:\junk" & "\"
Path1 = Path & "1.pdf"
Path2 = Path & "2.pdf"
Path3 = Path & "3.pdf"
Path4 = Path & "4.pdf"
Dim WshShell As IWshRuntimeLibrary.WshShell
Set WshShell = CreateObject("Wscript.Shell")
WshShell.CurrentDirectory = "C:\Program Files\Adobe\Acrobat 8.0\Acrobat\"
WshShell.Run "Acrobat.exe"
Set gApp = CreateObject("AcroExch.App")
Set gPDDoc = CreateObject("AcroExch.PDDoc")
Set gAVDoc = CreateObject("AcroExch.AVDoc")
'Set iPDDocSource = CreateObject("AcroExch.PDDoc")
ok = gAVDoc.Open(Path1, "1") 'This works
ok3 = gPDDoc.InsertPages(0, iPDDocSource, 0, 1, 0)
'<-- Problem here with iPPDocSource
Set gAVDoc = Nothing
End Sub

I am an absolute hack when it comes to programming in Visual Basic. In the past as a Structural Engineer I have programmed a lot in Fortran, but I have also written programs in a lot of other languages as well. However, programming is not my primary job, but I am better at it than your first impression implies, but not by much. I accidentally omitted the Sub MergePDF() text at the top of the code. This routine is part of a larger program run from MS Excel VBA that is already complete. Yes I do tend to kludge stuff together until it works, thats what examples are for. Therefore I made multiple dims and other declarations that aren't necessary because I do not have a familiarity with the Adobe SDK. However, the Acrobat SDK is not as intuitively obvious to the casual observer as you would have me believe. It seems to be written more for the C and Java programmers. All of that aside you did help me solve my problem so thank you. Thanks Reinhard for the code that may give me other ideas to explore. The following code was all I required for my current application.
Sub MergePDF()
Dim Path1 As String, Path2 As String, Path3 As String, Path4 As String
Dim gPDDoc1 As AcroPDDoc
Dim gPDDoc2 As AcroPDDoc
Dim gPDDoc3 As AcroPDDoc
Dim gPDDoc4 As AcroPDDoc
Set gPDDoc1 = CreateObject("AcroExch.PDDoc")
Set gPDDoc2 = CreateObject("AcroExch.PDDoc")
Set gPDDoc3 = CreateObject("AcroExch.PDDoc")
Set gPDDoc4 = CreateObject("AcroExch.PDDoc")
chk1 = gPDDoc1.Open("C:\junk\1.pdf")
chk2 = gPDDoc2.Open("C:\junk\2.pdf")
chk3 = gPDDoc3.Open("C:\junk\3.pdf")
chk4 = gPDDoc4.Open("C:\junk\4.pdf")
mergefile = gPDDoc1.InsertPages(0, gPDDoc2, 0, 1, 0)
mergefile = gPDDoc1.InsertPages(1, gPDDoc3, 0, 1, 0)
mergefile = gPDDoc1.InsertPages(2, gPDDoc4, 0, 1, 0)
savemergefile = gPDDoc1.Save(1, "C:\junk\merged.pdf")
End Sub

Similar Messages

  • Write the results script of results log pane to XLS or CSV file with VBA.

    Hi,
    How can I write the results script of results log pane to XLS or CSV file with VBA code or something? I tried so hard but i can't.
    Thanks

    MoGas,
    This is actually not a trivial process. You need to use the results object and code it to write to your file (it is described in the help files).
    e-Tester automatically saves the results log as a text file so you may just want to stick with that for simplicity.

  • How to share files with windows xp

    how to share files with windows xp

    stephenfromdagenaham wrote:
    how to share files with windows xp
    If you mean just moving files between a Mac and a PC with XP on it, get a USB flash drive, format it FAT32 (they usually come that way) and copy the files to that drive.

  • I am trying to find out how to assign files with particular extensions to the appropriate software. At the moment when I create a file using Word it is apparently given the extension .docx but Word doesn't recognise its own files. How do I alocate th

    I am trying to find out how to assign files with particular extensions to the appropriate software. At the moment when I create a file using Word it is apparently given the extension .docx but Word doesn't recognise its own files. How do I allocate the extension .docx to Word? There used to be a way of doing it, I think under "Preferences" but I can't seem to find it.

    Still in the same location:
    File > Get Info > Open with (select) > Change All (button)

  • How to merge rows with similar values in alv grid display in webdynpro

    Hi experts,
                   i want to know about how to merge rows with similar values in alv grid display of webdynpro.grouping rows is possible in table display in webdynpro but i am not able to do row grouping in the alv grid display in webdynpro.
    kindly suggest.
    thanks ,
    Anita.

    Hi Anita,
    did you find a solution for this? I have opened a Thread, if you know the answer maybe you could help me out:
    Is there an ALV function similar to the TABLE Row grouping?
    Thanx in advanced!!!
    Kind Regards,
    Gerardo J

  • How to create file with APDU

    Hello everybody,
    It's my first time using Java Card ^_^,I want to create a file and fill the fill with binary data.but i don't know how to create file with APDU commands,so I need help here.
    I think that there must be a Manual of the JavaCard's OS in this world,can someone tell me where to download it??
    Thanks.
    the fllowing is my card:
    Samsung S1
    Model:TiEx-32J
    EEPROM size:32k
    Platform Version:OP 2.0.1
    Card Manager Status:OP_READY
    KMC:40~4F/No derivation
    Message was edited by:
    AllenHuang

    If you look around the forum for a bit, you will see that there is no notion of file systems on JavaCards (lexdabear posted this information less than two hours ago :-)). To store files, you will have to write an applet to hold byte arrays of the required size and handle receiving and sending of these.
    As for documentation, you should have a look at the GP (General Platform) specification at http://www.globalplatform.org/, which defines communication between smart cards and other devices, as well as Sun's own JavaCard pages (http://java.sun.com/products/javacard/), which contain several useful resources on JavaCards.
    Message was edited by:
    Lillesand

  • How to attach file with an email in travel and expenses

    Hi Experts,
    I am new to sap cloud application studio.
    We have requirement that need to attach any type of files in the mail,
    I have gone through this : How to send an email with attachments in SAP Cloud Application Studio
    But compilation error at import AP.FO.ACTIVITY.GLOBAL., so not able to work with that lines of code.
    I am using these lines of code to send email.
    EMailUtilities.SendEMail(lang, bcc, cc, toAddress, htmlContent, from name, subject);
    So am not able to getting how to attach file with this code.
    Please help me regarding this.
    Thanks & Regards,
    Preethi Ande

    Hi Preethi,
         I am trying to send mail from custom BO in Travel on Demand System.I am getting  compilation error.please look into the attached screenshot for the code.
    Please assist me on this,                                Thanks in advance
    regards,
    Sendhilazhagan

  • Sum Encrypt does not recognize a copy of a file through linux. How decrypt this file with Sum Encrypt?

    Sum Encrypt does not recognize a copy of a file through linux to Mac 0S9. How decrypt this file with Sum Encrypt?

    Hello, and welcome to Apple Support Communities!
    I am not familiar with the program that you list, however files in OS 9 use things called Resource Forks (rather than file extensions) for filetype and creator.
    If you sent a file through Linux these resource forks probably got stripped and now the file is nothing to your Macintosh.
    It is best to BinHex your files (.hqx) before leaving the HFS file system so that their resource forks are preserved.
    Regards,
    Ryan

  • How to share files with sony smart tv

    How do I share files on mac with my sont smart tv?

    stephenfromdagenaham wrote:
    how to share files with windows xp
    If you mean just moving files between a Mac and a PC with XP on it, get a USB flash drive, format it FAT32 (they usually come that way) and copy the files to that drive.

  • Adobe Creative Cloud - How To Share Files With Clients and Colleagues | Creative Suite Podcast: Designers | Adobe TV

    In this episode of the Adobe Creative Suite Podcast, Terry White shows how to share Photoshop, Illustrator and InDesign Files with clients and colleagues and all they'll need is a browser to comment and see your Photoshop Layers.
    http://adobe.ly/10ZjpE4

    Terry,
    I guess I miss something. How can I share a folder of photos? When I return from a shoot, I select 20 of the pictures and need to share them with my client to pick up the favorites. Am I supposed to copy and past an URL for each image separately?
    Sometimes I also work with a colleague, I need to share my favorites with him. Same issue.
    We have tried Adobe Cloud, and then went for Dropbox. There we can share a folder and he can put even his pictures in it as well. That's what I call collaboration. And it is free (unlike Adobe Cloud). If you have some word in Adobe, please tell them to either drop it and make a deal with services like Dropbox, or make it properly.
    Thanks.
    Vaclav

  • How to share files with others?

    Hello! I wanna share some files with my home mates who are both Windows users. I wonder how to do it.
    Thanks

    If you open up your system preferences, and along the Internet row, you should see a "Sharing" icon. Within there you would have the option to enable Windows File Sharing.
    You may want to try this feature and follow the instructions within that preferences pane.
    If this doesn't prove to be worthy, try establishing a connection through the internet (if available). Otherwise you could simply burn CD's from your Mac and transfer them that way to the PC's. This is of course if your Mac is a CD burner.
    Hope this helps.

  • Create many thousands PDFs from Word files with VBA

    Hi,
    I create many thousands of word files from an excel file through VBA.
    I need to transalte these word files in pdf files.
    How can I do it ?
    Possible in VBA ?
    Possible to translate all the files in a directory from word to PDF ?

    Hi BrunoOrleans,
    You can use the 'Action Wizard' in Acrobat to convert a folder of word files to pdf.
    Regards,
    Rave

  • How to read files with codepage UTF16LE with "Sender File Adapter"

    Hi everybody,
    I am using a XI-Filesender-Adapter to get a (UTF-16LE encoded) file und process it in XI-Mapping.
    This is my File-Content:
    Cost Centre,Cost Code,Page Count (B&W),Page Count (Colour),Job Count
    Unknown,Lexmark,"37,480",334,"11,968"
    Unknown,Unknown,312,0,177
    110000,Lexmark,128,228,43
    The HEX-representation of this content is:
    FF FE 43 00 6F 00 73 00 74 00 20 00 43 00 65 00
    (The starting 2 Bytes FF FE represent UTF16-LE )
    And this is the payload I get for mapping:
    <?xml version="1.0" encoding="utf-8" ?>
    <ns:MT_POM_KOSTEN xmlns:ns="http://aua.com/pom">
    <POM_REC>
      <COSTCENTER>uFEFFCost Centre</COSTCENTER>
      <COSTCODE>Cost Code</COSTCODE>
      <PAGECOUNT_BW>Page Count (B&W)</PAGECOUNT_BW>
      <PAGECOUNT_COL>Page Count (Colour)</PAGECOUNT_COL>
      <JOBCOUNT>Job Count</JOBCOUNT>
      </POM_REC>
    <POM_REC>
      <COSTCENTER>Unknown</COSTCENTER>
      <COSTCODE>Lexmark</COSTCODE>
      <PAGECOUNT_BW>37,480</PAGECOUNT_BW>
      <PAGECOUNT_COL>334</PAGECOUNT_COL>
      <JOBCOUNT>11,968</JOBCOUNT>
      </POM_REC>
    <POM_REC>
      <COSTCENTER>Unknown</COSTCENTER>
      <COSTCODE>Unknown</COSTCODE>
      <PAGECOUNT_BW>312</PAGECOUNT_BW>
      <PAGECOUNT_COL>0</PAGECOUNT_COL>
      <JOBCOUNT>177</JOBCOUNT>
      </POM_REC>
    <POM_REC>
      <COSTCENTER>110000</COSTCENTER>
      <COSTCODE>Lexmark</COSTCODE>
      <PAGECOUNT_BW>128</PAGECOUNT_BW>
      <PAGECOUNT_COL>228</PAGECOUNT_COL>
      <JOBCOUNT>43</JOBCOUNT>
      <POM_REC>
    I can see the correct strings (for example Cost Centre) in  payload, but the string-comparison in the user defines function cannot recognize the equality of the strings:
    for (int i =0; i < a.length; i++) {
    if (
       (a<i>.equals("Cost Centre"))  )
      result.addSuppress();
    else
      result.addValue("");
    Actually I am using UTF-8 as codepage in Fileadapter (and Text as type)
    When I try to use UTF16 (or UTF-16LE) as Codepage, I am getting unreadable characters.
    I also tried binary, UTF16-BE,...
    The only way is to covert the file to ANSI before  I use it with XI. Then my function does work correctly.
    Does anybody have an idea, how I can read a UTF16-LE File and process it correctly in XI?
    I am using XI 7.00 0023  and JSDK 1.4.2-34
    Thanks a lot
    Armin

    Hello Armin,
                        I have gone through some SAP notes and blogs  to find solution to your problem, here is what I found
    1. SAP NOTE 821267
    q) How do I correctly configure the File Encoding used by the File
    Adapter?
    Flat Files with File Content Conversion
    For a File Sender channel, configure the encoding of the source
    file. The file will be interpreted according to the configured
    encoding and converted to XML with an UTF-8 encoding.
    For a File Receiver channel, configure the encoding to match
    the encoding you would like to be written to the target flat
    file.
    - Flat Files without File Content Conversion
    Whether to configure an encoding in this case depends on if you
    want to pass through the file "as is", e.g. within a File
    Sender to File Receiver scenario, or if you want to convert the
    file's encoding on its way through the Integration Server. For
    "as is" processing, configure both the sender and the receiver
    using the File Type setting "Binary".
    To apply an encoding conversion, configure the respective
    source and target encoding in both the sender and receiver
    channel.
    Important: Configuring an encoding in the receiver channel
    will only lead to the expected results if the payload sent to
    the receiver channel is in UTF-8 format (e.g., by having
    specified an encoding conversion in the Sender channel).
    So as per this note if you configure the encoding scheme of sender communication channel to UTF-16LE, adapter should be able to convert it to UTF-8 by default. But you have posted that this encoding scheme is leading to unreadable charcters
    2) SAP note 880173
    This speaks of use of module XMLAnonymizerBean which can be applied to XML payload to change its encoding.
    3) How to guide on encoding : http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42?QuickLink=index&overridelayout=true
    4) SAP note:960663
    http://help.sap.com/saphelp_nw04/helpdata/en/45/da2deb47812e98e10000000a155369/content.htm
    TextCodePageConversion Bean details which might solve your problem.
    5) Finally if nothing above works you need  a java mapping code to convert to target XML structure without any File content conversion. The mapping will convert the received file to proper target XML in "UTF-8" encoding. Please let us know if you need help on the code with this final option.
    Regards
    Anupam

  • How to save file with the "/" symbol in the name?

    Hi,
    I have Adobe Professional 8.  I need to save files with names that include the symbol /, but Adobe interprets, for example, A/88/6, as file name 6, in a folder named 88, in a folder named A, and sets up new folders to accommodate that.  I cannot substitute another symbol as I already have thousands of pdf files in a database using the / symbol, and I need them in the same folders.
    I would very greatly appreciate any advice,
    thanks,
    Mo.

    Thanks.
    As I said, I'm pretty ignorant about these things.  I wouldn't know how to begin using a "hack".  All I know is that I was able, for over a year, to save .pdf files directly from my browser on several computers, and use the forbidden "/" symbol in every file name.  After saving the files, Adobe will happily open them, and allow me to edit and re-save them, although I now see that it will not allow me to "save as" them under a different name without removing that symbol.
    I may not be tech-savvy, but I can state that everything I have said here and above is entirely accurate.  I would be happy to open a dropbox account to show you countless .pdfs with the symbol "/" in the name.
    This is honestly not that big a deal.  I greatly appreciate this discussion, and you have inspired me to become slightly less computer-ignorant.
    Hope you all had a great New Year.  I am still recovering.
    Cheers,
    Mo.

  • How to send file with original name through Mail adapter

    I have to send file with original name as attachment through Mail Adapter. I am picking the file from FTP server through File Adapter. I am not using message mapping because files do not have any standard format.

    Hi,
    Have you solve your problem ?...
    I have exactly the same scenario : pik up a file (file adapter) and send it in attachment by mail adapter without mapping (no IR)...
    I activated Adapter specific paramters properties in the File adapter sender and i can see the FileName tag in DynamicConfiguration section of SoapHeader in SXMB_MONI...
    I want to use MessageTransformationBean... BUT, how can i 'access' to FileName tag ???...
    Thanks...
    I setup modules like this :
    AF_Modules/DynamicConfigurationBean 1
    AF_Modules/MessageTransformBean rename
    sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean mail
    1 key.0 write http://sap.com/xi/XI/System/File FileName
    1 value.0 message.FileName
    rename Transform.ContentDisposition attachment;filename=message.FileName
    rename Transform.ContentDescription message.FileName
    rename Transform.ContentType application/csv-tab-delimited-table;name=message.FileName
    But my file name attachment is message.FileName....
    Edited by: Emmanuel JORAND on Sep 29, 2008 9:23 PM
    Edited by: Emmanuel JORAND on Sep 29, 2008 10:25 PM

  • How to merge files in Quicktime 10

    Merging files in QT 7 was so easy. Move the play head of video 1 to the end and then drag/drop video 2 over the video 1 window and save. Easy. How do you merge files in QT 10?

    How do you merge files in QT 10?
    You don't. Use QT 7.6.3 Pro, MPEG Streamclip, or a similar application.

Maybe you are looking for

  • I never received my deposit refund of $250

    I was told that my refund would be returned after a year of subscription as long as I have no late payments. I made the deposit on oct 12 last year and I have no late payments. I called the financial services a few days before oct 12 of this year and

  • File opens only in Pages

    I create a document in Pages 08 and save it to the desktop. When I click on the desktop icon later, a message pops up telling me it cannot be opened. So I have to go into Pages, and open it using Recent Items. Obviously, this is a big problem. What a

  • Buildng team in org management in hr

    hi guys, could any one help me with the code..org management is new to me... i have to build teams for head quaters:Teams are formed by Org Unit ID and Supervisor Position ID. From the root node, for each position, check if position is a supervisor u

  • Satellite U840W - Panel Open - Power On - unable to disable

    I have a Satellite U840W - the display doesn't have a lock on close, so would power on in a laptop bag. I was able to disable this in the Toshiba System Settings tool. However, a recent update means that even though the setting is Disabled, it will s

  • Need start point

    what is the best way or the best technology to develop gui-database web application???(not applets)