Catching File->Open and File->Close 
Author Message
 Catching File->Open and File->Close

How can I do this?

When a user is in any application, like Word, Excel, etc.and when the
user selects File->Open to open
a file or File->Close to Close a file. I want my program to be notified.

What is the best way to it?

Thanks

Mike

Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.



Sun, 13 Jan 2002 03:00:00 GMT  
 Catching File->Open and File->Close
Install a hook(SetWIndowsHookEx()) to get messages (WH_GETMESSAGE) for all
windows (or for that process). Look for WM_COMMAND with appropriate ID
(File, New etc) for t the window you are interested in.

--
Ajay Kalra

Quote:

>How can I do this?

>When a user is in any application, like Word, Excel, etc.and when the
>user selects File->Open to open
>a file or File->Close to Close a file. I want my program to be notified.

>What is the best way to it?

>Thanks

>Mike

>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.



Sun, 13 Jan 2002 03:00:00 GMT  
 Catching File->Open and File->Close

Thanks for your reply,
This is what I am trying to do and I am not sure this can do it or not.

1. Assuming the user is in MSWORD
2. When the user selects File->Open to open a word document.
3. I need to catch the name of the file
4. Update some line to the document(Which includes, adding, removing,
etc. lines from the word document)
5. Then display the new word document to the user
6. When the user selects File->Close to close the document
7. I would like to catch the name of the file and perform similar
operation on the word document.

Can I use the SetWIndowsHookEx()to solve this? If so should I be using
the (WH_GETMESSAGE) or should I be using the (WH_CALLWNDPROC) function.

Thanks again

Mike



Quote:
> Install a hook(SetWIndowsHookEx()) to get messages (WH_GETMESSAGE) for
all
> windows (or for that process). Look for WM_COMMAND with appropriate ID
> (File, New etc) for t the window you are interested in.

> --
> Ajay Kalra


> >How can I do this?

> >When a user is in any application, like Word, Excel, etc.and when the
> >user selects File->Open to open
> >a file or File->Close to Close a file. I want my program to be
notified.

> >What is the best way to it?

> >Thanks

> >Mike

> >Sent via Deja.com http://www.deja.com/
> >Share what you know. Learn what you don't.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


Mon, 14 Jan 2002 03:00:00 GMT  
 Catching File->Open and File->Close

Hooks are not going to solve this feature that you want. You need to
automate Word and use its exposed API to get document and other information.
You would be better served to post you questions in a Word or Automation
related news group.

--
Ajay Kalra

Quote:

>Thanks for your reply,
>This is what I am trying to do and I am not sure this can do it or not.

>1. Assuming the user is in MSWORD
>2. When the user selects File->Open to open a word document.
>3. I need to catch the name of the file
>4. Update some line to the document(Which includes, adding, removing,
>etc. lines from the word document)
>5. Then display the new word document to the user
>6. When the user selects File->Close to close the document
>7. I would like to catch the name of the file and perform similar
>operation on the word document.

>Can I use the SetWIndowsHookEx()to solve this? If so should I be using
>the (WH_GETMESSAGE) or should I be using the (WH_CALLWNDPROC) function.

>Thanks again

>Mike



>> Install a hook(SetWIndowsHookEx()) to get messages (WH_GETMESSAGE) for
>all
>> windows (or for that process). Look for WM_COMMAND with appropriate ID
>> (File, New etc) for t the window you are interested in.

>> --
>> Ajay Kalra


>> >How can I do this?

>> >When a user is in any application, like Word, Excel, etc.and when the
>> >user selects File->Open to open
>> >a file or File->Close to Close a file. I want my program to be
>notified.

>> >What is the best way to it?

>> >Thanks

>> >Mike

>> >Sent via Deja.com http://www.deja.com/
>> >Share what you know. Learn what you don't.

>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.



Mon, 14 Jan 2002 03:00:00 GMT  
 Catching File->Open and File->Close

Thanks again.

I was just assuming that if the user is in Word, The user
could be any application which deals with File-Open.

Does that mean, I need to have some kind of a patch for each
application?

Thanks

Mike



Quote:

> Hooks are not going to solve this feature that you want. You need to
> automate Word and use its exposed API to get document and other
information.
> You would be better served to post you questions in a Word or
Automation
> related news group.

> --
> Ajay Kalra


> >Thanks for your reply,
> >This is what I am trying to do and I am not sure this can do it or
not.

> >1. Assuming the user is in MSWORD
> >2. When the user selects File->Open to open a word document.
> >3. I need to catch the name of the file
> >4. Update some line to the document(Which includes, adding, removing,
> >etc. lines from the word document)
> >5. Then display the new word document to the user
> >6. When the user selects File->Close to close the document
> >7. I would like to catch the name of the file and perform similar
> >operation on the word document.

> >Can I use the SetWIndowsHookEx()to solve this? If so should I be
using
> >the (WH_GETMESSAGE) or should I be using the (WH_CALLWNDPROC)
function.

> >Thanks again

> >Mike



> >> Install a hook(SetWIndowsHookEx()) to get messages (WH_GETMESSAGE)
for
> >all
> >> windows (or for that process). Look for WM_COMMAND with appropriate
ID
> >> (File, New etc) for t the window you are interested in.

> >> --
> >> Ajay Kalra




- Show quoted text -

Quote:

> >> >How can I do this?

> >> >When a user is in any application, like Word, Excel, etc.and when
the
> >> >user selects File->Open to open
> >> >a file or File->Close to Close a file. I want my program to be
> >notified.

> >> >What is the best way to it?

> >> >Thanks

> >> >Mike

> >> >Sent via Deja.com http://www.deja.com/
> >> >Share what you know. Learn what you don't.

> >Sent via Deja.com http://www.deja.com/
> >Share what you know. Learn what you don't.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


Tue, 15 Jan 2002 03:00:00 GMT  
 Catching File->Open and File->Close
Note that File-Open could have any resource ID, so, yes, you would have to
have special versions for each application. And also making sure that newer
versions kept the same resource ID for the same command...

You would have to find out the ID, perhaps by loading the exe into the
resource editor, and then you would have to trap WM_COMMAND with that ID for
that particular application.

Johan Rosengren
Responsable Informatique
PACTA S.A.

Quote:

> I was just assuming that if the user is in Word, The user
> could be any application which deals with File-Open.

> Does that mean, I need to have some kind of a patch for each
> application?



Tue, 15 Jan 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. File Format conversion, ascii freeform -->.csv <-->.wk1<-->dbf<-->?HELP

2. Selecting multiple files in Win File->Open dialog

3. B>C>C++>VC++(MFC)>RAW API PROGRAMMING>ATL>COM>OLE>ADO>ASP.............

4. >>>>>>>>> What would you like in a debugger?

5. conversion: unsigned_char->file->unsigned_char ?

6. conversion: unsigned_char->file->unsigned_char ?

7. >> operator in files context

8. operator>> for file input to vector

9. opening >16 files in BC++ 3.0

10. Opening > 100 files under NT

11. <<<<<<<Parsing help, please>>>>>>>>

12. Opening files from IDE takes > 1 min

 

 
Powered by phpBB® Forum Software