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 SkipVought 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
0
0
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......
 
certain letters require a one-click print action

Require? Do you not mean.....it would be nice?

You state that it worked previously.....OK....so what is the problem again? If it is not working, please state what is happening.

Gerry
 
Requirements for this macro/module are:

To allow a custom button on the Word 2003 toolbar to send the open document to the networked HP LaserJet 4250dtn printer where two copies will be printed, one to Bond and the other to Plain paper.

Bond and Plain are both set as printer defaults in one of each of the available paper trays.

The code as it stands doesn't run with the new printer. All I did was change the printer name from the old 4050 printer to the name of the new printer as it is known on the network.

Nothing.

No errors, no pop-ups, no annoying debug messages and no print jobs sent.

I'd settle for two buttons that each performed one of the print jobs (Bond and Plain) and just make sure the PC users click once on each.

No clue how to do this effectively - like I said, my VB/VBA skills suck....
 
Ok, when you manually send thse print jobs, separately....does it print?

Gerry
 
Yes, if the print jobs are sent manually (File >> Print >> Select Printer >> Printer Properties >> Select paper type) then they print OK.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top