Macro that Prompts user to print.

B

bajanboost

Hey All.
I have made a document that has 8 (eight) labels to ONE page. Th
document is divided into 4 rows by 2 coloumns. Each label goes into
cell of its own

I have made 7 macros so that a user can choose to print any amount o
labels from 1-8 by just pressing any of the short cut keys
The first macro is shift+F7 which would delete one of the first label
and then print the other 7
The second macro is shift+F6 which would delte the first two label
and continue to print the other 6. And so on..

This is all well and good. If a user wants to print 8, he needs to d
nothing but print the document as it is, because it is at default,
labels

The challenge lies where I want a user to get a prompt when they pres
print, whcih would have a box appear and say
"how many would you like to print?
the user then could input the amount they wish to print and the macr
automatically interprets that amount and prints that exact amount

So if a user wanted to print 9 labels, it would print ONE full shee
of 8 and then on another sheet, it shall only print 1

Is there anyone out there that can do this? If you need more info t
make the situation clear, just let me know. Thank You
 
J

Jezebel

Write a macro called FilePrint -- it will run in place of the built in print
command.
 
A

Anand.V.V.N

I fell there is a better solution, Since you say you have labels, what you
can do is

have a text box in which the user will enter the number of lables he wants
to print, while printing hide the text box.

Or if you assume that user will print the number of labels in which there is
input or data, detect which have data and print only those labels with have
some data hide the rest.
Hope you foudn this helpful

Anand
 
C

Charles Kenyon

Your solution is more cumbersome than intercepting the print command.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
C

Charles Kenyon

See http://word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
D

David Sisson

Another approach:

You don't say whether all the labels are the same, but I will assume
they are.

Using your document, delete all but the first label. Save the doc as a
template. Add an AutoOpen routine that asks the user, "How many labels
to print?" Take the answer and populate the new document with as many
labels as requested.
 
C

Charles Kenyon

Yes, when I said "your solution" I meant the solution you suggested in your
posting.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
A

Anand.V.V.N

Hi Charles,

I thought it gave the programmer more control and made it very easy for the
user, any way why would you say it is more cumbersome than intercepting the
print command.

Anand
 
A

Anand.V.V.N

Oh that way, its just needs one fuction actually, I suggested this becuase I
had a similar problem and I had no other way to do it, so I suggested that
way.

Anand
 
C

Charles Kenyon

An intercept, if done well, is virtually invisible to the user. It does not
require that the user do anything different in your application to achieve
the results you want.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
A

Anand.V.V.N

Yea ture I agree, but when I did that thing I didn't have any other choice,
and of course the user ented the input in only the coloums that he wante to
print, so I had to do it that way.

Anand
 
C

Clint

When you intercept the print, it only intercepts the File-Print command but
not the Print Button on the toolbar. Is there another place to place this
FilePrint code so it does intercept the Print Button on Toolbar???
 
C

Charles Kenyon

I believe you also need to intercept FilePrintDefault.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
C

Clint

Is there a BeforePrint and AfterPrint procedure I can use to set a few
options before printing??
 
C

Charles Kenyon

Sorry, someone else will have to answer that. I have exhausted my limited
vba knowledge.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
D

Dawn Crosier

From Help: (Word 2003)

DocumentBeforePrint Event
Occurs before any open document is printed.

Private Sub object_DocumentBeforePrint(ByVal Doc As Document, Cancel As
Boolean)

object An object of type Application declared with events in a class
module. For more information about using events with the Application object,
see Using Events with the Application Object.

Doc The document that's being printed.

Cancel False when the event occurs. If the event procedure sets this
argument to True, the document isn't printed when the procedure is finished.

Example
This example prompts the user for a yes or no response before printing any
document. This code must be placed in a class module, and an instance of the
class must be correctly initialized in order to see this example work; see
Using Events with the Application Object for directions on how to accomplish
this.

Public WithEvents appWord as Word.Application

Private Sub appWord_DocumentBeforePrint _
(ByVal Doc As Document, _
Cancel As Boolean)

Dim intResponse As Integer

intResponse = MsgBox("Have you checked the " _
& "printer for letterhead?", _
vbYesNo)

If intResponse = vbNo Then Cancel = True
End Sub
I could not find anything suitable for AfterPrint

--
Dawn Crosier
Microsoft MVP
"Education Lasts a Lifetime"

This message is posted to a newsgroup. Please post replies and questions to
the newsgroup so that others can learn as well.
 
J

Jean-Guy Marcil

Clint was telling us:
Clint nous racontait que :
Is there a BeforePrint and AfterPrint procedure I can use to set a few
options before printing??

Write the macro to do the stuff you want.

Then, as Charles pointed out, call this macro from a macro called FilePrint
and also from FilePrintDefault.

Otherwise, use Dawn's advice about BeforePrint.

There is no AfterPrint event. If after printing is important, you have to go
the first way.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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