Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Word - print macro/VBA module

Status
Not open for further replies.

Xunil

Technical User
Dec 17, 2002
27
GB
This is the situation:


The brief version is this – HP LaserJet 4250dtn in Windows Server 2003 (Standard) Active Directory and shared to all network users as their default printer.

My apologies if this is classed as dual posting of the same thread/problem.

Anyway, certain letters require a one-click print action to print two copies of the letter. One copy goes onto Bond paper from one printer tray while the second goes onto Copy paper in the other printer tray.

This is some code I’m playing with, which worked perfectly on an older HP LaserJet 4050 attached to my own Windows Server 2003 network.

Sub hp()
Attribute hp.VB_Description = "Macro recorded 10/09/05 by Xunil"
Attribute hp.VB_ProcData.VB_Invoke_Func = "Normal.NewMacros.hp"
'
' hp Macro
' Macro recorded 10/09/05 by Xunil
'
ActivePrinter = "HP LaserJet 4050 TN PCL 6"
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
End Sub
Sub PrintLetterandCopy()
Attribute PrintLetterandCopy.VB_Description = "Macro recorded 10/09/05 by Xunil"
Attribute PrintLetterandCopy.VB_ProcData.VB_Invoke_Func = "Normal.NewMacros.PrintLetterandCopy"
'
' PrintLetterandCopy Macro
' Macro recorded 10/09/05 by Xunil
'
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(1)
.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(1)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.4)
.FooterDistance = InchesToPoints(0.25)
.PageWidth = InchesToPoints(8.27)
.PageHeight = InchesToPoints(11.69)
.FirstPageTray = wdPrinterLargeCapacityBin
.OtherPagesTray = wdPrinterLargeCapacityBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = True
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
End With
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(1)
.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(1)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.4)
.FooterDistance = InchesToPoints(0.25)
.PageWidth = InchesToPoints(8.27)
.PageHeight = InchesToPoints(11.69)
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterLowerBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = True
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
End With
End Sub

You can probably get the idea of where I’m trying to go with this.

I want to be able to click a button in Word 2003 and have two copies of the open Word document printed – one will be printed to Bond paper in one tray of the printer while the other will be printed to Copy (standard copy paper) in the other printer tray.

My VB/VBA skills suck big time and this is doing my head in. It’s reaching the stage where outside assistance will have to be called in to resolve this client requirement.

Any thoughts on how this could be set up to actually work ?

Please......
 

Please post in the VBA Visual Basic for Applications (Microsoft) Forum707

Skip,
[sub]
[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top