Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-03-2011, 11:05 PM
socrates01 socrates01 is offline NEED macro to save word doc as pdf Windows Vista NEED macro to save word doc as pdf Office 2007
Novice
NEED macro to save word doc as pdf
 
Join Date: Jul 2011
Posts: 2
socrates01 is on a distinguished road
Default NEED macro to save word doc as pdf

Hi guys,

I run a mail merge on a regular basis the output of which is a work document that has over 2000 pages. i use the below macro to split out the pages and save them into individual documents. What i really need as the end product is a set of individual pdf documents off the back of the mail merge. is there a way to to do this directly in the mail merge or alternatively can anyone help me in modifying the below macro so that when it splits the pages up it automatically saves the individual documents as pdf's.


Code:
Sub Splitter()
    Selection.EndKey Unit:=wdStory
    numlets = Selection.Information(wdActiveEndSectionNumber)
    If numlets > 1 Then numlets = numlets - 1
    Selection.HomeKey Unit:=wdStory
    BaseName = "D:\Documents and Settings\Desktop\Test mail merge\XXX"
    For Counter = 1 To numlets
        DocName = BaseName & Right("0" & LTrim(Str(Counter)), 10)
        ActiveDocument.Sections.First.Range.Cut
        Documents.Add
        Selection.Paste
        Selection.MoveLeft Unit:=wdCharacter, Count:=1
        Selection.Delete Unit:=wdCharacter, Count:=1
        ActiveDocument.SaveAs FileName:=DocName
        ActiveWindow.Close
    Next Counter
End Sub
Any help would be much appreciated

Thanks,
XXX
Reply With Quote
  #2  
Old 07-04-2011, 01:22 AM
macropod's Avatar
macropod macropod is offline NEED macro to save word doc as pdf Windows 7 64bit NEED macro to save word doc as pdf Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Hi socrates01,

Modifying you code to save as PDF is quite simple! Change:
ActiveDocument.SaveAs FileName:=DocName
to:
ActiveDocument.SaveAs FileName:=DocName, FileFormat:=wdFormatPDF

PS: When posting code, please use code tags.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 07-10-2011, 10:30 PM
socrates01 socrates01 is offline NEED macro to save word doc as pdf Windows Vista NEED macro to save word doc as pdf Office 2007
Novice
NEED macro to save word doc as pdf
 
Join Date: Jul 2011
Posts: 2
socrates01 is on a distinguished road
Default

Thanks very much for the code, it works perfectly. Except for one thing. when i run the macro it starts splitting the doucment and saving the individual files as pdf's but for every file plit it prompts me to save/don't save/cancel the saving of the document as a .docx format as well. As i will be using this macro of many thousands of pages (hence many individual files) prompts will not be useful. can anyone help out?

Many thanks,
XXX
Reply With Quote
  #4  
Old 07-11-2011, 05:12 AM
macropod's Avatar
macropod macropod is offline NEED macro to save word doc as pdf Windows 7 64bit NEED macro to save word doc as pdf Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Hi socrates01,

Try changing the line:
ActiveWindow.Close
to:
ActiveWindow.Close SaveChanges = False
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
document, macro, save

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
NEED macro to save word doc as pdf Macro to save as pdf with ability to choose save as folder rvessio Word VBA 4 07-25-2016 12:37 PM
NEED macro to save word doc as pdf Macro to save as PDF but with a different name shabbaranks Word VBA 2 05-20-2011 01:02 AM
Macro to Save Help clarkson001 Word 0 02-14-2011 06:41 AM
NEED macro to save word doc as pdf Word Macro: Save file as text with current file name jabberwocky12 Word VBA 2 10-22-2010 12:23 PM
Macro Won't Save lou0915 Word VBA 2 10-17-2009 08:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:35 PM.


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