Thread: [Solved] Splitting Out PDFs
View Single Post
 
Old 12-04-2012, 05:11 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by 4mysanity View Post
The first part of the code (the first sub routine) is supposed to split out each paragraph number. The second part of the code (the part you did) - is supposed to insert the images to the pdfs that are going to be created.

Since there are two macro's in two different sub's would it be better if they were combined as one macro?
Frankly, I'm not sure what your 'Splitter' macro is supposed to achieve that that second macro doesn't already do. The document you've provided has no Section breaks, so there is only ever one Section to process and all that would happen, if anything, is that the document as a whole would be saved as a PDF. That said, the 'Splitter' code could be made much more efficient:
Code:
Sub Splitter()
Dim numlets As Long, Counter As Long, sPath As String, DocName As String
numlets = ActiveDocument.Sections.Count
If numlets > 1 Then numlets = numlets - 1
sPath = "k:\test\images\"
For Counter = 1 To numlets
  DocName = sPath & Format(Counter, "000")
  ActiveDocument.Sections.First.Range.Cut
  Documents.Add
  With ActiveDocument.Range
    .Paste
    .Characters.First = vbNullString
    .SaveAs2 FileName:=DocName, FileFormat:=wdFormatPDF
    .Close
  End With
Next Counter
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote