Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 11-30-2012, 07:17 PM
macropod's Avatar
macropod macropod is offline Splitting Out PDFs Windows 7 64bit Splitting Out PDFs 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

Try:
Code:
Sub InsertPicsToPDF()
Application.ScreenUpdating = False
Dim Para As Paragraph, Str As String, i As Long, Rng As Range, sPath As String
sPath = "K:\test\images\"
With ActiveDocument
  For Each Para In .Paragraphs
    Str = Trim(Para.Range.Words.First)
    If Str Like "###" Then
    Set Rng = Para.Range
      With Rng
        .InsertBefore Chr(12)
        .Collapse wdCollapseEnd
        .InsertAfter vbCr
        .Collapse wdCollapseStart
        .ParagraphFormat.Alignment = wdAlignParagraphCenter
      End With
      .InlineShapes.AddPicture FileName:=sPath & Str & ".jpg", _
        LinkToFile:=False, SaveWithDocument:=True, Range:=Rng
    End If
  Next
  .Characters.First.Delete
  For i = 1 To .ComputeStatistics(wdStatisticPages)
    Set Rng = ActiveDocument.GoTo(What:=wdGoToPage, Name:=i)
    Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\page")
    If Rng.Characters.Last = Chr(12) Then Rng.MoveEnd wdCharacter, -1
    Str = Trim(Rng.Words.First)
    Rng.Copy
    Documents.Add
    With ActiveDocument
      .Range.Paste
      .SaveAs2 FileName:=sPath & Str & ".pdf", FileFormat:=wdFormatPDF, AddToRecentFiles:=False
      .Close SaveChanges:=False
    End With
  Next
End With
Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
As I don't know what your 'Splitter' sub is about, I haven't really given it much consideration, though I note your 'SaveAs' won't work - you need 'SaveAs2'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserted PDFs become Pixelated in Powerpoint fongchun PowerPoint 0 11-26-2012 06:24 PM
Splitting Out PDFs My Word 2007 doesnt display PDFs correctly mattk561 Word 8 10-31-2012 08:04 PM
Splitting Out PDFs Embedding PDFs in MS Word 2010 chitownbillj Word 1 06-30-2012 12:01 AM
Creating High Quality PDFs from Word 2010 BrazzellMarketing Word 11 01-27-2012 01:06 PM
Splitting Out PDFs Converting Powerpoint into Fully Accessable PDFs KCD123 PowerPoint 4 09-28-2011 10:03 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:54 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft