VBA Code to Change Printer Properties when Printing from Word

L

LDMueller

I need VBA code to accomplish what I manually have to do as follows:

I have a Word document and I go to Printer Setup and set it up for A4 paper.
I also have the code for this. Unfortunately I have to manually go to
File, Print, Properties and on the Paper/Quality tab under Paper Options I
need to change the size to A4.

Can anyone help me with the code for the Printer Properties.

Adding another driver for the different settings is not an option.

Any assistance would be greatly appreciated.
 
R

Roger Whitehead

Hi LD

Sub SetA4()
'landscape -
With ActiveDocument.PageSetup
.Orientation = wdOrientLandscape
.PageWidth = CentimetersToPoints(29.7)
.PageHeight = CentimetersToPoints(21)
End With

'or portrait -
With ActiveDocument.PageSetup
.Orientation = wdOrientPortrait
.PageWidth = CentimetersToPoints(21)
.PageHeight = CentimetersToPoints(29.7)
End With
End Sub
 
L

LDMueller

Hi Roger,

Thank you for your response. I tried this code, but all it did was change
the page setup to A4. This part I already had covered.

The part I can't seem to code is the equivalent of going to File, Print from
Word and going to Properties and on the Paper/Quality tab under Paper Options
changing the size to A4.

I'm sorry I didn't explain it well initially. What I'm trying to accomplish
is not having to go to the printer and pressing the button for paper change.

Does this make sense?

Thanks,
LD
 
R

Roger Whitehead

Sorry - you did point at this - I missed it.

What paper size is the document initially set to or defaulting to?

Roger
 
H

Helmut Weber

hi LDMueller,

there is an option in "tools, options, print"

options.MapPaperSize = True

If it helps, it's alright.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
H

Helmut Weber

Yes

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
L

LDMueller

Thank you for your response. Unfortunately, this doesn't solve my issue.
Normally we have the "Allow A4/Letter paper resizing" option on, but this
forces us to have to go to the printer and press a button so the pages start
printing. If I change the "Allow A4/Letter paper resizing" setting to off,
the job prints automatically and prints on A4 paper (which is what I need),
but is formatted for "letter" which is wrong.

This is why I really need to be able to code the equivalent of going to
File, Print from Word and going to Properties and on the Paper/Quality tab
under Paper Options changing the size to A4.

Thanks,

LD
 
J

Jonathan West

LDMueller said:
I need VBA code to accomplish what I manually have to do as follows:

I have a Word document and I go to Printer Setup and set it up for A4
paper.
I also have the code for this. Unfortunately I have to manually go to
File, Print, Properties and on the Paper/Quality tab under Paper Options I
need to change the size to A4.

Can anyone help me with the code for the Printer Properties.

Adding another driver for the different settings is not an option.

Any assistance would be greatly appreciated.

What you are trying to do is not all that straightforward. Controlling the
printer from VBA is sufficiently awkward that I wrote a series of articles
about it. This may help

Controlling the Printer from Word VBA
Part 1: Using VBA to Select the Paper Tray
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=101

Controlling the Printer from Word VBA
Part 2: Using VBA to control Duplex, Color Mode and Print Quality
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=116

Controlling the Printer from Word VBA
Part 3: Dealing with Different Paper Sizes
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=132

Controlling the Printer from Word VBA
Part 4: Getting printer driver details
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=183
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top