Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word: printPreview

Status
Not open for further replies.

andre65

Programmer
Jan 19, 2003
95
NL
In my app I want to give the user the possibility to directly print a Word document or to preview a Word document.

I have created a class which supports both requests. I use the following code to create the class

lparameters tnInvoiceNr, tnOutput
*-- tnInvoiceNr = invoice number to print
*-- tnOutput = c_PRN_TO_PRINTER of c_PRN_PREVIEW
loInvoice = createObject('_word')
loInvoice.m_print(tnInvoiceNr,tnOutput)
release loInvoice

In the _word class I have a method m_print, which contains:
...
if tnOutput=c_PRN_PREVIEW
this.oWord.visible = .t.
this.oDocNew.printpreview
this.oWord.visible = .f.
else
...
endif

Now when i run my app using print preview, i see word showing up and hides after one second or so.

I already tried the following
this.oWord.visible = .t.
this.oDocNew.printpreview
=inkey()
this.oWord.visible = .f.

Assuming the preview will show up, the user can close Word. How does FoxPro handles the procedure calls referring to the Word's object, I think a runtime error occurs.

So, what is the best way for previewing a word document.

André
 
You've got it backwards...

For what I believe you want to do, you should leave the
Word instance invisible, invoke the printpreview() method,
then make the Word instance visible. (Word also has a
printpreview property, but the following will apply just
the same)

The problem you'll encounter of course is how to detect
when the preview window in Word is closed.

Review the google search for pointers:

Darrell
 
I use VFP70. BindEvent is for VFP80, isn't it?

André
 
I didn't have my development system up for a while.

I just verified that the previously mentioned dll:
vfpcom.dll, does indeed work with Visual FoxPro 6.

Matter of fact, it works with Visual FoxPro 5.

Darrell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top