468,539 Members | 1,856 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,539 developers. It's quick & easy.

MS Word and Printing

I have my Word document being created in a seperate thread. THe applicaiton
is not visible.

The end user can choose to view the document upon completion or just have it
print.

Viewing is fine.

If htey choose to "just print it" it seems ot ignore this command:

oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)

and a prompt appears asking that it wait until printing is complete. I
beleive it is because it is getting to my "kill thread" command at that
point.

In addition when I ask that it cancel the print job in the Word dialog that
appears, something like a print preview screen appears. (I use MS Word
2003). Then the save file dialog appears

Is there a way to just offer to save it, print it, and kill the thread
without this inteference from Word? I am probably missing something here.

I need this to work with Office 2000 and up.....

oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)
OfficeThread.IsBackground = False
oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)
Try
OfficeThread.IsBackground = True
Label28.Text = "Printing Report..."
Label28.Refresh()
OfficeThread.IsBackground = False
oDoc.Application.PrintOut()
OfficeThread.IsBackground = True
oDoc.Application.Quit()
OfficeThread.Abort()
Nov 20 '05 #1
4 1861
Hi 53061

If the code you've posted is what you're executing you've got a problem
sure enough. The statement:
oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)

is invalid! And since it's outside your Try block the Catch exception
handler is not grabbing it! Try using:

oDoc.Application.Dialogs.Item(wdDialogFileSaveAs). Show

or if you have the Word applicat object rather than the document object
use:
wdApp.Dialogs.Item(wdDialogFileSaveAs).Show

HTH + Cheers - Peter
"scorpion53061" <Its the end of the world as we know it@here.com> wrote in
news:#L**************@TK2MSFTNGP11.phx.gbl:
I have my Word document being created in a seperate thread. THe
applicaiton is not visible.

The end user can choose to view the document upon completion or just
have it print.

Viewing is fine.

If htey choose to "just print it" it seems ot ignore this command:

oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)

and a prompt appears asking that it wait until printing is complete. I
beleive it is because it is getting to my "kill thread" command at that
point.

In addition when I ask that it cancel the print job in the Word dialog
that appears, something like a print preview screen appears. (I use MS
Word 2003). Then the save file dialog appears

Is there a way to just offer to save it, print it, and kill the thread
without this inteference from Word? I am probably missing something
here.

I need this to work with Office 2000 and up.....

oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)
OfficeThread.IsBackground = False
oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)
Try
OfficeThread.IsBackground = True
Label28.Text = "Printing Report..."
Label28.Refresh()
OfficeThread.IsBackground = False
oDoc.Application.PrintOut()
OfficeThread.IsBackground = True
oDoc.Application.Quit()
OfficeThread.Abort()


Nov 20 '05 #2
Also check out the arguments of the PrintOut command. Set the background
argument to False so that the balance of your code does not execute until
the printing is complete.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"scorpion53061" <Its the end of the world as we know it@here.com> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
I have my Word document being created in a seperate thread. THe applicaiton
is not visible.

The end user can choose to view the document upon completion or just have
it
print.

Viewing is fine.

If htey choose to "just print it" it seems ot ignore this command:

oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)

and a prompt appears asking that it wait until printing is complete. I
beleive it is because it is getting to my "kill thread" command at that
point.

In addition when I ask that it cancel the print job in the Word dialog
that
appears, something like a print preview screen appears. (I use MS Word
2003). Then the save file dialog appears

Is there a way to just offer to save it, print it, and kill the thread
without this inteference from Word? I am probably missing something here.

I need this to work with Office 2000 and up.....

oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)
OfficeThread.IsBackground = False
oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)
Try
OfficeThread.IsBackground = True
Label28.Text = "Printing Report..."
Label28.Refresh()
OfficeThread.IsBackground = False
oDoc.Application.PrintOut()
OfficeThread.IsBackground = True
oDoc.Application.Quit()
OfficeThread.Abort()

Nov 20 '05 #3
ok, by setting it to false it did this correctly. Thanks...

The save file prompt occurs when the application is exiting - how do you
suppress that?
"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
<dk*@mOSTvALUABLEpROFESSIONALs.org> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...
Also check out the arguments of the PrintOut command. Set the background
argument to False so that the balance of your code does not execute until
the printing is complete.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"scorpion53061" <Its the end of the world as we know it@here.com> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
I have my Word document being created in a seperate thread. THe applicaiton is not visible.

The end user can choose to view the document upon completion or just have it
print.

Viewing is fine.

If htey choose to "just print it" it seems ot ignore this command:

oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)

and a prompt appears asking that it wait until printing is complete. I
beleive it is because it is getting to my "kill thread" command at that
point.

In addition when I ask that it cancel the print job in the Word dialog
that
appears, something like a print preview screen appears. (I use MS Word
2003). Then the save file dialog appears

Is there a way to just offer to save it, print it, and kill the thread
without this inteference from Word? I am probably missing something here.
I need this to work with Office 2000 and up.....

oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)
OfficeThread.IsBackground = False
oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)
Try
OfficeThread.IsBackground = True
Label28.Text = "Printing Report..."
Label28.Refresh()
OfficeThread.IsBackground = False
oDoc.Application.PrintOut()
OfficeThread.IsBackground = True
oDoc.Application.Quit()
OfficeThread.Abort()


Nov 20 '05 #4
Hi

Set the Document objects Saved property to True.

HTH + Cheers - Peter

"scorpion53061" <Its the end of the world as we know it@here.com> wrote in
news:e#**************@TK2MSFTNGP11.phx.gbl:
ok, by setting it to false it did this correctly. Thanks...

The save file prompt occurs when the application is exiting - how do you
suppress that?
"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS" <dk*@mOSTvALUABLEpROFESSIONALs.org> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...
Also check out the arguments of the PrintOut command. Set the background
argument to False so that the balance of your code does not execute until the printing is complete.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"scorpion53061" <Its the end of the world as we know it@here.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
>I have my Word document being created in a seperate thread. THe

applicaiton > is not visible.
>
> The end user can choose to view the document upon completion or just have > it
> print.
>
> Viewing is fine.
>
> If htey choose to "just print it" it seems ot ignore this command:
>
> oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)
>
> and a prompt appears asking that it wait until printing is complete. I
> beleive it is because it is getting to my "kill thread" command at that > point.
>
> In addition when I ask that it cancel the print job in the Word dialog
> that
> appears, something like a print preview screen appears. (I use MS Word
> 2003). Then the save file dialog appears
>
> Is there a way to just offer to save it, print it, and kill the thread
> without this inteference from Word? I am probably missing something here. >
> I need this to work with Office 2000 and up.....
>
> oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)
>
>
> OfficeThread.IsBackground = False
> oDoc.Application.Dialogs.Item(wdDialogFileSaveAs)
> Try
> OfficeThread.IsBackground = True
> Label28.Text = "Printing Report..."
> Label28.Refresh()
> OfficeThread.IsBackground = False
> oDoc.Application.PrintOut()
> OfficeThread.IsBackground = True
> oDoc.Application.Quit()
> OfficeThread.Abort()
>
>




Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Stefania Scott | last post: by
10 posts views Thread by Jeff B. | last post: by
reply views Thread by Karthik | last post: by
1 post views Thread by Laurent Navarro | last post: by
1 post views Thread by Derek Hart | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.