Using Word as an *ONLY PREVIEW* application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to use Word 2002 as a "Viewer" of documents that I create "on the fly" using automation. It is working mostly as I expected, I already changed the Menu to remove all options I do not need etc, but eventhough I start word in preview mode, whenever I click the "x" button to close the preview window, it goes back to "edit" mode, when I was expecting the application to close, not just the preview. If from the preview window I click "quit", it works fine, it comes back to my program. So, the question is, how can I make "Preview" the only window accessible to the user

My code is

loWord = Createobject('word.application'
loDocument = loWord.Documents.Add(
* Add content to the document her
*---
loDocument.PrintPreview=tru
loWord.PrintPreview=tru

(Now, pressing the "x" windows button in the preview window, I want word to close aswell

Hope it is clea
 
Create a withevents reference to the word application, then trap the
WindowDeactivate event. You'll have to use early binding, and create a class
module with a declaration like

private withevents loWord as Word.Application

The listbox at the top left of the code window will now include loWord. If
you select it, the right-hand listbox will show the events you can trap.
WindowDeactivate is fired for ANY window change, not just closing the
PrintPreview window.


HugoR said:
I want to use Word 2002 as a "Viewer" of documents that I create "on the
fly" using automation. It is working mostly as I expected, I already changed
the Menu to remove all options I do not need etc, but eventhough I start
word in preview mode, whenever I click the "x" button to close the preview
window, it goes back to "edit" mode, when I was expecting the application to
close, not just the preview. If from the preview window I click "quit", it
works fine, it comes back to my program. So, the question is, how can I make
"Preview" the only window accessible to the user?
 
Jezebel, catching the event was something I wanted to try, but was not sure of what event handle. I will try to use your suggestion, although I am not sure how to do it withing Visual FoxPro, which is the language we use. I will let you know if it worked!
 
Word's VBA Help covers the application object, and lists its properties,
methods, and events. There are only 12 events, so it's not a lot of reading.
There's also a Help topic 'Using Events with the Application Object'. You
can find this info also via the ObjectBrowser.



HugoR said:
Well, I found how to do it in VFP, but I need a list of all the events of
Word.Application, which seems to be none?? I can not find a list of events,
even in the MS page there are only Properties and Methods listed, but no
event??
It might be to early in the morning, I need more coffee!!
http://msdn.microsoft.com/library/d...-us/dv_wrcore/html/wrgrfapplicationobject.asp
 
Thanks Jezebel, I solved the problem, although not using the events (I tried, and I found the event definitions, I just do no understand why they are not listed in the link I posted). In the end, I just did something like this

loWord = createobject('word.application'
loDocument = loWord.Documents.add(
loWord.PrintPreview = .t
loWord.ActiveWindow.ActivePane.view.zoom.PageFit = 1 && wdPageFitFullPag
loWord.WindowState = 1 && wdWindowStateMaximiz
loDocument.Saved = .t

* Set up document settings and add conten

* Message Using custom dialog ('You must close the preview window or press esc to continue'
loWord.visible = .t
do while Type("loWord.ActiveWindow.Caption")="C" and "preview" $ Lower(loWord.ActiveWindow.Caption
if inkey(.25) = 2
exi
endi
endd
loWord.quit(.f.
Dialog.Release(

This works quite well
 
No I remember why I hated FoxPro. Felicitations none the less.


HugoR said:
Thanks Jezebel, I solved the problem, although not using the events (I
tried, and I found the event definitions, I just do no understand why they
are not listed in the link I posted). In the end, I just did something like
this:
 
Back
Top