Macro for Paper Size

F

Francis Marquez

I was wondering if there is a way to create a macro that simply allows the
user to change the paper size ?

(Besides going to Page Setup and changing it there)
 
J

Jonathan West

Francis Marquez said:
I was wondering if there is a way to create a macro that simply allows the
user to change the paper size ?

(Besides going to Page Setup and changing it there)

ActiveDocument.PageSetup.PaperSize = <page size>

Choose the page size from among the constants defined for the purpose.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
F

Francis Marquez

Thanks for the response. Does this work for any time of printer or driver
(native)?
A little more background info.

We are converting from WP8 (ouch) to Word 2003 and we are trying to assist
users with custom macros.

One macro we wanted brought over from WP8 is the Paper Size selector.

The goal is to have the end-users click on one button on the toolbar and
give them the option to print the document to whatever tray they want
depending on the paper size.

Another question is would this also work for custom forms?
 
J

Jonathan West

Francis Marquez said:
Thanks for the response. Does this work for any time of printer or driver
(native)?

Yes, the Page Setup is independent of printer.
A little more background info.

We are converting from WP8 (ouch) to Word 2003 and we are trying to assist
users with custom macros.

One macro we wanted brought over from WP8 is the Paper Size selector.

In that case, you might not need a macro at all. Just go to File, Page
Setup, click the Paper Size tab, and make your selection.

The goal is to have the end-users click on one button on the toolbar and
give them the option to print the document to whatever tray they want
depending on the paper size.

Ah, that starts getting a bit more compled. Printer and papertray handling
isn't well-managed in Word. You might want to look at a series of articles I
wrote on the topic a while back.

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
Another question is would this also work for custom forms?

If they are protected using the Protect Document command, you would have to
temporarily unprotect, change the page setup, then reprotect.

You'll see a demonstration of how to do that (albeit for a different
purpose) in this article

How to enable the spellchecker in a protected document
http://www.word.mvps.org/FAQs/MacrosVBA/SpellcheckProtectDoc.htm
 
F

Francis Marquez

Wow, thanks for the links, I'll be sure to read up and apply them.

Thanks a bunch.
 
F

Francis Marquez

Hi Jonathan,

I looked at those articles and will have a colleague review them further.

I guess the answer I am looking for is, after all is said and done, is our
goal of having a "Macro button of some sort on the toolbar that end-users can
push to select the paper size they want" attainable? If so, how much
programming time will it take?

The alternative is to train them to go through page setup and select it from
there.

Thanks
 
J

Jonathan West

Francis Marquez said:
Hi Jonathan,

I looked at those articles and will have a colleague review them further.

I guess the answer I am looking for is, after all is said and done, is our
goal of having a "Macro button of some sort on the toolbar that end-users
can
push to select the paper size they want" attainable?

How do you define "the paper size they want?
If so, how much
programming time will it take?

Depends on the answer to the question above. Anyway, as i understood, it,
your question isn't quite what you seemed to mean before. You seemed to be
asking

"Can the paper tray be selected automatically to match the paper size of the
current document?"

To which the answer is "yes", and the code in my articles will help you get
there.
 
F

Francis Marquez

Paper size?
I work for a law firm and printing to Bond paper is common.
Plain paper is in Tray 2.
Bond paper is in Tray 1.
We are trying to create a button on the tool bar whereby if a user clicks on
it, the document can be directed to any of the trays above, for any printer.
 
J

Jonathan West

Francis Marquez said:
Paper size?

Yes, paper size. I thought you were asking about paper size, that being the
subject of your original post.

I work for a law firm and printing to Bond paper is common.
Plain paper is in Tray 2.
Bond paper is in Tray 1.
We are trying to create a button on the tool bar whereby if a user clicks
on
it, the document can be directed to any of the trays above, for any
printer.

That's a common enough situation.

Go into the Page setup dialog.You will find that you can define the First
Page as coming from one tray and Other Pages as coming from another tray.

If you define the template this way and save it, documents created using the
template will inherit those settings.

There are two potential problems, which might or might not occur depending
on your precise situation.

1. The ID codes used to identify the different paper trays vary between
makes & models of printer, so a template set up for one printer probably
will not print right for a different printer. The way to handle this is to
detect what make & model of printer is being used, and to adjust the tray
settings accordingly at the time you print a document.

2. If you want to print duplex, having the Other Pages tray different from
the first page , what happens is that the first page will print from one
tray, but instead of the second page printing on the back of the first, it
will print from the other tray. To handle this, you will need to separately
print the first two pages to the first tray, and then change the tray
settings and print the rest of the document from the other tray.

The series of articles I posted earlier will help you on these points, if
they are an issue to you.
 

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