Macro

P

Preet

Please can someone help me if possible, I am creating a macro, an
basically this is what I want it to say

"If the user clicks on File > Print or on Print Then print the documen
and then close the file with No changes saved"

I have NO idea how to do this, Ive used various "IF" statements but al
either Print when the document is opened and close automatically, o
they dont print at all

Can anybody help?

Please Note: The User must choose whether they want to Print or not, s
it isnt mandatory, hence I cannot just display the Print dialogue box

Any help would be most appreciated!

Thank you!!!
 
D

Doug Robbins

Give your macro the name of the built-in commands that you want it to
replace and use the following commands

With ActiveDocument
.PrintOut Background: = False
.Close wdDoNotSaveChanges
End With
--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
P

Preet

Hi Doug

And thank you for your reply, I really appreciate it!

BUT How do I find out the names of these "built-in commands"?

The macro so far says:

ActiveDocument.PrintPreview

and then carries onto closing the template its been formed from.

I then want the document that the Print Preview is being done on to
close without saving changes if the user clicks on exit


Sorry to ask loads of questions, I am very new to VBA, hence I have NO
CLUE

Thank you in advance.

Preet x
 
D

Doug Robbins

From the Tools>Macro>Macros dialog, use the "Macros in" pull-down and select
Word commands and you will then see a list of the command names.

For your VBA related questions, you would be better off to post to
microsoft.public.word.vba.beginners.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 

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