Event firing for Word

R

Raj

Dear All,

I would like to know that when MS word starts which event (VB Editor) is
fired. Very specifically I want to know the event that can be captured before
Word opens a blank document or before opening a file. Something similar to
the counterpart in word to Form Activate.

Basically I want this event to manipulate the properties of the file/ blank
document word opens before opening the complete file iteself.

Regards
Raj
 
J

Jezebel

That makes no sense. In order to trap a Word event (in VB) you have to have
a reference to the Word application object; and that reference is meaningful
only if the application object is running -- ie, by using CreateObject or
GetObject (or the equivalent Set ... statements): so either the application
object is already running when you get the reference to it, or it starts
because you instantiate it explicitly.
 
R

Raj

What you said is right!! There is the crux of the problem that there is no
object or reference that we are aware of. But what is the object or reference
when we fire the event activate form? In that case I guess form is the main
object.

Similarly when Word starts the main screen (Word's parent MDI form) is
loaded and then the individual word files can be categorized into the
children MDI forms which can be opened using the open file option. Second
when I try to open a file some event prior to File open must be firing which
studies the feature of the file. Lets say the file is password protected.
Then that event identifies the features of the file and prompts the user to
enter the password. This clearly indicates that some activity is going on
prior to opening of the file. It is this event which I am interested in.

Regards and Thanks for the prompt response.
Raj
 
R

Raj

What you said is right!! There is the crux of the problem that there is no
object or reference that we are aware of. But what is the object or reference
when we fire the event activate form? In that case I guess form is the main
object.

Similarly when Word starts the main screen (Word's parent MDI form) is
loaded and then the individual word files can be categorized into the
children MDI forms which can be opened using the open file option. Second
when I try to open a file some event prior to File open must be firing which
studies the feature of the file. Lets say the file is password protected.
Then that event identifies the features of the file and prompts the user to
enter the password. This clearly indicates that some activity is going on
prior to opening of the file. It is this event which I am interested in.

Regards and Thanks for the prompt response.
Raj
 
J

Jezebel

Not sure that I understand your question. The Word events that VB can trap
are fired by the Word application object, or by any document objects to
which you have a reference. This has nothing whatever to do with the windows
that Word might use to display its documents. In fact, if you instantiate
Word yourself --

Set pWordApp = new Word.Application

Word is hidden and has no windows or forms at all. But it's events are still
fired. Nor is Word an MDI application. Even if Word is visible, its windows
do not fire events. Only the app and the documents. There is no event fired
BEFORE a document is opened. If you are opening the document from VB --

set pWordDoc = pWordApp.Documents.Open(....)

then it's up to your code to deal with the password problem (as an argument
to the Open function). If the document is opened by the user, then THEY deal
with the password, and the Word application will fire an event when the
document has been opened successfully.
 

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