Application.Visible = true does not focus on the application

M

melon

I have a Outlook macro that will generate a customized Word document
for a given meeting request. I found out PrintOut does not give you a
print dialog box so I just set Application.Visible = true to let the
user print the stuff themselves.

However, sometimes Word will appear but remain in the background. I
think this is due to the Outlook prompt "Some program is trying to
access an address from Outlook". Is there any way that I can either

a) Bring up the print dialog window
b) Focus (bring to front) the word document.
 
S

Shauna Kelly

Hi melon

If appWord is a reference to the Word application, then try
appWord.Activate

That should bring Word to the front and give it the focus.

If docMyDocument is a reference to the document you've created, then try
docMyDocument.Activate

That should bring docMyDocument to the front and give it the focus.

Finally, if you want to display the print dialog box, activate the
relevant document, and then
Dialogs(wdDialogFilePrint).Show
For more information about that, see

Getting help with calling Word's built-in dialogs using VBA (and why
doing so can be much more useful than you'd think)
http://www.word.mvps.org/FAQs/MacrosVBA/TaskPanesReference.htm

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

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