Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2007

Tip: Looking for answers? Try searching our database.

Word macro help- formatting and printing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JAnderson - 26 Feb 2007 16:38 GMT
Greetings,

I'm trying to create a simple formatting and printing macro, but am having
some trouble.  I want the following to happen when the macro is run:

Select All
Font size to 8
Landscape format
Margins: Top .4, Bottom/left/right .5
Then print to a PDF using an add-in

Questions:
What if I want to give the macro to other users on different PCs?  How do I
get it into their Normal.dot template?

How can I create a message box asking if the user wants to convert the
document into a PDF?

I used the macro recorder to get the following code, and it seems excessive:

Sub Macro1()

   Selection.WholeStory
   Selection.Font.Size = 8
   With ActiveDocument.Styles(wdStyleNormal).Font
       If .NameFarEast = .NameAscii Then
           .NameAscii = ""
       End If
       .NameFarEast = ""
   End With
   With ActiveDocument.PageSetup
       .LineNumbering.Active = False
       .Orientation = wdOrientLandscape
       .TopMargin = InchesToPoints(0.4)
       .BottomMargin = InchesToPoints(0.5)
       .LeftMargin = InchesToPoints(0.5)
       .RightMargin = InchesToPoints(0.5)
       .Gutter = InchesToPoints(0)
       .HeaderDistance = InchesToPoints(0.5)
       .FooterDistance = InchesToPoints(0.5)
       .PageWidth = InchesToPoints(11)
       .PageHeight = InchesToPoints(8.5)
       .FirstPageTray = wdPrinterDefaultBin
       .OtherPagesTray = wdPrinterDefaultBin
       .SectionStart = wdSectionNewPage
       .OddAndEvenPagesHeaderFooter = False
       .DifferentFirstPageHeaderFooter = False
       .VerticalAlignment = wdAlignVerticalTop
       .SuppressEndnotes = False
       .MirrorMargins = False
       .TwoPagesOnOne = False
       .BookFoldPrinting = False
       .BookFoldRevPrinting = False
       .BookFoldPrintingSheets = 1
       .GutterPos = wdGutterPosLeft
   End With
   ActivePrinter = "X Consulting PDF Publisher"
   Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
       wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
       ManualDuplexPrint:=False, Collate:=True, Background:=True,
PrintToFile:= _
       False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
       PrintZoomPaperHeight:=0
End Sub
Shauna Kelly - 26 Feb 2007 20:53 GMT
Hi JAnderson

> What if I want to give the macro to other users on different PCs?  How do
> I
> get it into their Normal.dot template?

You don't! Leave users' normal.dot files alone. Instead, distribute your
macro in an add-in. For further information, see
Distributing macros to other users
http://www.word.mvps.org/FAQs/MacrosVBA/DistributeMacros.htm

> How can I create a message box asking if the user wants to convert the
> document into a PDF?

Something like this:

If MsgBox("Do you want to print to PDF?", vbYesNo) = vbYes Then
   'put the code to print here
Else
   'put here any code to run if the user says no
End If

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

> Greetings,
>
[quoted text clipped - 64 lines]
>        PrintZoomPaperHeight:=0
> End Sub
JAnderson - 26 Feb 2007 21:16 GMT
Thanks for the help!  I'll start using that right now!

Jason

> Hi JAnderson
>
[quoted text clipped - 91 lines]
> >        PrintZoomPaperHeight:=0
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.