Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split and Merge pages of a PDF attachment in an Outlook VB Macro 2

Status
Not open for further replies.

CooterBrown

IS-IT--Management
Aug 17, 2001
125
US
Hello,

I was tasked with pushing PDF attachments to our image system using a VB Macro from Outlook. Easy enough to do by itself but there is an additional requirement to direct certain pages of the attachment to one folio in the image system and other pages to a different folio. In the event the user doesn't separate these different documents when they submit them, our home office users must select which pages go to which area.

I have Adobe 9.0 Pro Extended installed but the users only have Reader.


I think the best way to approach this is to have the document opened for viewing and select pages via some control (chkbox?) to save in to a separate document. So, if pages 1, 8, 22-24 were selected, create a new pdf in the image queue with those pages only. Maybe this isn't possible with users that only have Reader installed, in which case another method could be suggested?


If I can just get a general idea on how to accomplish this, what libraries to reference and a snippet or two of code, I can probably put the rest together. Can anyone out there help me out with a direction to head?


Thanks!
 
Well, in Adobe Acrobat Standard (and I'm sure Extended), you can select Document - Extract, and choose whether or not to delete the extracted pages from the original document... then save the new document to a new file name...

Is that what you're looking for?

Also, if other software can be installed (free), and the users can't all have Acrobat Standard, and it needs to be user-level accomplished, then they could all use PDFill Tools - the Tools part is free, the editor costs. The tools part is free whether or not it's for comercial business, but the editor is actually pretty cheap anyway.

I personally have the responsibility of splitting out some documents on a regular basis at work. I currently use Adobe Standard for that, but previously, I used PDFill tools, and in some ways, I much preferred that to Acrobat.

--

"If to err is human, then I must be some kind of human!" -Me
 
That is nice, kjv!!
That will sure come in handy from time to time.
[thumbsup]

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
KJV... Sorry.. I don't remember getting your reply to my post.

That is what I'm looking to do. I need to extract some pages from a PDF doc attached to an email and assemble the remaining pages to be shipped to an image system.

A sender sometimes scans in multiple documents as one pdf file and attaches them and my users need to seperate the documents and ship the to the different folio areas in the image system.

I will PDFill Tools and see what it is and if it can help me.
 
Yes, PDFill Tools is very nice. Of course, when you first install it, it installs a link to the PDF Editor, which is not free, and tells you you can purchase it for ONLY this price. Well, if their editor is anything like the free tools selection, then I'd say it's a good editor, and worth whatever the price was.

Or, as I said, if you have Adobe Acrobat Standard (or above), you can also just use Document - Extract to take care of it. I have to handle several documents like this at least once per month. Sometimes more frequently, but at least once per month. Both methods have worked very well to my liking.

--

"If to err is human, then I must be some kind of human!" -Me
 
I have to handle several documents like this at least once per month. Sometimes more frequently, but at least once per month.
And you have Acrobat Standard?
I once wrote a PDF-Splitter for such purposes, perhaps it'll do for you too.
Just set a reference to "Acrobat.tlb", and this code will split a pdf into single one-pages PDFs. Works also when cycling through all PDFs in a folder.
Code:
Dim PDDoc As Acrobat.CAcroPDDoc, newPDF As Acrobat.CAcroPDDoc
Dim PDPage As Acrobat.CAcroPDPage
Dim thePDF as String, PNum as Long

'...
Set PDDoc = CreateObject("AcroExch.pdDoc")
Result = PDDoc.Open(thePDF)
If Not Result Then
   MsgBox "Can't open file: " & FileName
   Exit Sub
End If

'...
PNum = PDDoc.GetNumPages

For i = 0 To PNum - 1
    Set newPDF = CreateObject("AcroExch.pdDoc")
    newPDF.Create
    NewName = "Page_" & i "_of_" & PNum & ".pdf"
    newPDF.InsertPages -1, PDDoc, i, 1, 0
    newPDF.Save 1, NewName
    newPDF.Close
    Set newPDF = Nothing
Next i

Only works with a full Acrobat of course.
:)

Cheers,
MiS

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Thanks, MakeItSo. That looks like something I'd like to try out just to see. However, I don't always know exactly how many pages go with each file to be split out. And actually, Adobe has a checkbox option that says, "Split out each page to a separate file." So in reality, it wouldn't really help. Also, I'd have to open the files anyway in order to find the proper naming for the file.

But thankfully it's not hundreds or thousands of files (at this point). If it were, or ever becomes such, I'll look a little more seriously at an automation option for sure! [wink]

And actually, I could customize it to some extent, to where it would work 95% of the time, but for the 5%, I'd probably end up doing twice the amount of work, if it split them in the wrong place.

Now if there were a way to search for so much white space, or certain images (since scanned in) or something, THEN I could automate it. But I doubt it's worth it.

--

"If to err is human, then I must be some kind of human!" -Me
 
kjv1611 said: "Or, as I said, if you have Adobe Acrobat Standard (or above), you can also just use Document - Extract to take care of it. I have to handle several documents like this at least once per month. Sometimes more frequently, but at least once per month. Both methods have worked very well to my liking. "

KJV... thanks! I do have the Adobe Acrobat Pro but I'm writing a utility in VB6 (started as a macro - now is an add-in) and some of the intended users ONLY have the reader. I think you're saying this will not work for them and they need to upgrade.

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top