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