Printing Macros Problem

Microsoft Office word 2007
August 4, 2010 at 03:51:39
Specs: Windows XP
I am a very inexperienced with Macros and would appreciate greatly if anyone could help me with this.

So we got a new printer (HP Laserjet P3015DN) and have it installed in the network. We currently have macros which worked perfectly that allow our users to print different drays (Tray 1, Tray 2, Tray 3, Tray 4 & a combination of 2 and 4). Our current macros that worked on our previous printer are now not working so I went to try and record new macros but it hasn’t gone well. The printer now does correctly print the desired paper color but it also changes all of the margins, thereby messing with the formatting of the letter and making it unusable. I would like it not to hold margin settings and just to what our old macros do and print exactly what it sees on the screen. The macro is huge compared to the 7 line previous Macro.

I am posting the code which would print of 1x Tray 1 and 1x Tray 4. It is huge and you can clearly see the margin settings in there but I do not know how to tidy it up:

Sub LHCopy()
'
' LHCopy 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.35)
        .BottomMargin = CentimetersToPoints(6)
        .LeftMargin = CentimetersToPoints(2.2)
        .RightMargin = CentimetersToPoints(2.35)
        .Gutter = CentimetersToPoints(0)
        .HeaderDistance = CentimetersToPoints(1.27)
        .FooterDistance = CentimetersToPoints(2)
        .PageWidth = CentimetersToPoints(21)
        .PageHeight = CentimetersToPoints(29.7)
        .FirstPageTray = 260
        .OtherPagesTray = wdPrinterFormSource
        .SectionStart = wdSectionNewPage
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = True
        .VerticalAlignment = wdAlignVerticalTop
        .SuppressEndnotes = False
        .MirrorMargins = False
        .TwoPagesOnOne = False
        .BookFoldPrinting = False
        .BookFoldRevPrinting = False
        .BookFoldPrintingSheets = 1
        .GutterPos = wdGutterPosLeft
    End With
    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
    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.35)
        .BottomMargin = CentimetersToPoints(6)
        .LeftMargin = CentimetersToPoints(2.2)
        .RightMargin = CentimetersToPoints(2.35)
        .Gutter = CentimetersToPoints(0)
        .HeaderDistance = CentimetersToPoints(1.27)
        .FooterDistance = CentimetersToPoints(2)
        .PageWidth = CentimetersToPoints(21)
        .PageHeight = CentimetersToPoints(29.7)
        .FirstPageTray = 262
        .OtherPagesTray = wdPrinterFormSource
        .SectionStart = wdSectionNewPage
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = True
        .VerticalAlignment = wdAlignVerticalTop
        .SuppressEndnotes = False
        .MirrorMargins = False
        .TwoPagesOnOne = False
        .BookFoldPrinting = False
        .BookFoldRevPrinting = False
        .BookFoldPrintingSheets = 1
        .GutterPos = wdGutterPosLeft
    End With
    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
    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.35)
        .BottomMargin = CentimetersToPoints(6)
        .LeftMargin = CentimetersToPoints(2.2)
        .RightMargin = CentimetersToPoints(2.35)
        .Gutter = CentimetersToPoints(0)
        .HeaderDistance = CentimetersToPoints(1.27)
        .FooterDistance = CentimetersToPoints(2)
        .PageWidth = CentimetersToPoints(21)
        .PageHeight = CentimetersToPoints(29.7)
        .FirstPageTray = wdPrinterFormSource
        .OtherPagesTray = wdPrinterFormSource
        .SectionStart = wdSectionNewPage
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = True
        .VerticalAlignment = wdAlignVerticalTop
        .SuppressEndnotes = False
        .MirrorMargins = False
        .TwoPagesOnOne = False
        .BookFoldPrinting = False
        .BookFoldRevPrinting = False
        .BookFoldPrintingSheets = 1
        .GutterPos = wdGutterPosLeft
    End With
End Sub

Thanks very much


See More: Printing Macros Problem

Report •

#1
August 4, 2010 at 06:12:00
Hi,

This is my best guess at what is essential:

Sub LHCopy()
' LHCopy Macro
    With ActiveDocument.Styles(wdStyleNormal).Font
        If .NameFarEast = .NameAscii Then
            .NameAscii = ""
            Else
            .NameFarEast = ""
        End If
    End With
    'setup page margins & 'other pages' tray
    With ActiveDocument.PageSetup
        .TopMargin = CentimetersToPoints(2.35)
        .BottomMargin = CentimetersToPoints(6)
        .LeftMargin = CentimetersToPoints(2.2)
        .RightMargin = CentimetersToPoints(2.35)
        .HeaderDistance = CentimetersToPoints(1.27)
        .FooterDistance = CentimetersToPoints(2)
        .OtherPagesTray = wdPrinterFormSource
    End With
    
    'first print - with first tray code
    ActiveDocument.PageSetup.FirstPageTray = 260
    Application.PrintOut

    'second print - with first tray code
    ActiveDocument.PageSetup.FirstPageTray = 262
    Application.PrintOut
    
    'third print - first page is same as 'other pages' tray
    ActiveDocument.PageSetup.FirstPageTray = wdPrinterFormSource
    Application.PrintOut
End Sub

I have changed the first section about style/font.
It looked wrong - but I really cannot be sure.
So you may want to change it back.

I have removed the lines that just set default settings to their defaults, and left in the margin setups and tray settings.

Hope this is of some help.

Regards


Report •
Related Solutions


Ask Question