setting up print macros in Word1010

January 18, 2013 at 03:14:40
Specs: Windows 7
Hi

I am receiving a runtime error 4605 message advising that the object refers to framed paragraphs. When i try to debug i get the following message which means nothing to me. can anyone advise in simple layman's terms what i do to resolve the problem? I have tried to create the macros in a word template doc but it still doesnt work :( many thanks

printing Macro
'
'
With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = CentimetersToPoints(2.54)
.BottomMargin = CentimetersToPoints(2.54)
.LeftMargin = CentimetersToPoints(2.54)
.RightMargin = CentimetersToPoints(2.54)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.25)
.FooterDistance = CentimetersToPoints(1.25)
.PageWidth = CentimetersToPoints(21)
.PageHeight = CentimetersToPoints(29.7)
.FirstPageTray = 260
.OtherPagesTray = 258
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = CentimetersToPoints(2.54)
.BottomMargin = CentimetersToPoints(2.54)
.LeftMargin = CentimetersToPoints(2.54)
.RightMargin = CentimetersToPoints(2.54)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.25)
.FooterDistance = CentimetersToPoints(1.25)
.PageWidth = CentimetersToPoints(21)
.PageHeight = CentimetersToPoints(29.7)
.FirstPageTray = 258
.OtherPagesTray = 258
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
End Sub


See More: setting up print macros in Word1010

Report •


#1
January 18, 2013 at 03:40:31
The first thing i notice is that you do not have a 'sub' for this macro, so this macro will not run.

just above the first line where you have 'With.........."

enter the following

Sub PrintMacro

So what you should have is


Sub PrintMacro
With ActiveDocument.Styles(wdStyleNormal).Font


Report •

#2
January 18, 2013 at 04:51:01
Hi many thanks for your response. I have added in what you advised but it is still not working. When i debug again, the line; -

.Orientation = wdOrientPortrait

is highlighted yellow. Does this indicate where the error is perhaps? if so what steps shoudl i take?

The strange thing is that i have had the macro working but then it just stops for some reason??


Report •

#3
January 18, 2013 at 05:30:23
A posting tip...

Please click on the blue line at the end of this post and read the instructions on how to post VBA code in this forum.

Thanks!

DerbyDad03
Office Forum Moderator

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •

Related Solutions

#4
January 18, 2013 at 06:05:20
Thanks Derbydad3 - should i re-post the code using your tip?

Report •

#5
January 18, 2013 at 07:28:58
For now it's OK but please try to use the pre method in the future since it makes reading the code a lot easier when the indents are retained.

Regarding your actual problem, I do not get any errors when I run the code. The only problem I have is that the code confuses my printer as far as which tray to take the paper from.

When I look at your code, I see 2 almost identicle sets of printout instructions. The only difference appears to be this line:

.FirstPageTray = 260

vs. this line:

.FirstPageTray = 258

When I run the code it prints some pages from the default tray and other pages from the manual feed tray.

What exactly is the code supposed to do?

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •


Ask Question