How to invoke Print Dialog Box in Visual Basic in OS X

F

Frost

I am trying to figure out how to make the Print Dialog box Display in
OS X when using a print command in Visual Basic for Word. The problem
is that when I use the PrintOut command to print the first 2 pages of a
document, it bypasses the print dialog box and prints to the default
printer, but it always uses the top tray on the printer no matter which
tray was used most recently. In OS 9 when it bypassed the the print
dialog you could get it to print to the proper tray by setting the tray
you wanted in a previous print dialog box, and it would default to that
tray.
In OS X it always goes to the top(usually wrong) tray if the dialog box
is not displayed.
So I am trying to find out if there is a way to force word to NOT
bypass the Print Dialog, so I can make sure the print goes to the
correct tray.

Any ideas?
 
J

Jim Gordon MVP

Hi Frost,

The way I would use is the one suggested in the help file.

Dialogs(wdDialogFilePrint).Show

This problem sounds like there's a bug in the printer driver. Have you
contacted the printer manufacturer?

-Jim
 
F

Frost

Jim,
Thanks for the idea. I think that is on the right track, but it does
not seem to do what I would expect. When I use the following code, it
does bring up the print dialog, but it does not fill in any of the
parameters (it just defaults to 1 copy, all pages. Can you tell me what
I'm doing wrong?

Here is the code I'm using
Sub PrintFirstTwoPages()
With Dialogs(wdDialogFilePrint)

.Range = 3
.From = 1
.To = 2
.NumCopies = 1
.Background = True
.Show

End With
End Sub
 
J

John McGhie [MVP - Word and Word Macintosh]

Hi:

You need to read the help topic "Displaying built-in Word dialog boxes"
several times (correction: *I* needed to read it several times...) to
understand the difference between .Show and .Execute.

When you do, you may choose to use the PrintOut method instead.

ActiveWindow.PrintOut Range:=wdPrintFromTo, From:="1", To:="3"

Use dialogs only if you want user input. Otherwise, use the base method
directly, else you will *get* user input when you least expect (or want...)
it.

Cheers


Jim,
Thanks for the idea. I think that is on the right track, but it does
not seem to do what I would expect. When I use the following code, it
does bring up the print dialog, but it does not fill in any of the
parameters (it just defaults to 1 copy, all pages. Can you tell me what
I'm doing wrong?

Here is the code I'm using
Sub PrintFirstTwoPages()
With Dialogs(wdDialogFilePrint)

.Range = 3
.From = 1
.To = 2
.NumCopies = 1
.Background = True
.Show

End With
End Sub

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 

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