Help: Same key stroke for different documents having different functionality

S

sk_uc04

Hello Everybody,

I am working on 3 word documents. I have set same key binding (Alt+F1)
for each one of them. If I press Alt+F1 on document 1, I get a message
"Hello Doc 1 User". If I press Alt+F1 on document 2, I get the message
"Hello Doc 2 user" and for document 3, I get "Hello Doc 3 User".

If I work separately/individually on the documents, the key binding
works great. If I have all the 3 documents open and switch between
documents i.e minimize one and work on the other, the key binding
doesn't work. That is it doesn'r show the appropriate message w.r.t
the document.

Can anybody suggest a better solution? Thanks for your help!

Regards,
SK
 
J

Jean-Guy Marcil

(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :
Hello Everybody,

I am working on 3 word documents. I have set same key binding (Alt+F1)
for each one of them. If I press Alt+F1 on document 1, I get a message
"Hello Doc 1 User". If I press Alt+F1 on document 2, I get the message
"Hello Doc 2 user" and for document 3, I get "Hello Doc 3 User".

If I work separately/individually on the documents, the key binding
works great. If I have all the 3 documents open and switch between
documents i.e minimize one and work on the other, the key binding
doesn't work. That is it doesn'r show the appropriate message w.r.t
the document.

Can anybody suggest a better solution? Thanks for your help!

Regards,
SK

You will need application events (DocumentChange) to monitor when user
switches between documents. This way you will be able to reassign the ALT-F1
key on the fly.

See:
http://word.mvps.org/faqs/macrosvba/AppClassEvents.htm


--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
K

Klaus Linke

Normally, keyboard shortcuts in the document should override anything in the
Normal template or even in the attached template, and should be quite
sufficient.

There might be some bugs lurking that keep that from working if you swith
between documents a certain way, but my first guess would be that the
shortcuts haven't really been saved in the document by accident... though it
would be hard to explain why the macro works with the docs opened
individually.

Two other things I don't quite understand about the original question: Where
are the macros stored that bring up the messages?

And is there really a need to have three different macros? Maybe one macro
(in Normal.dot or the attached template or in a global template, with the
keyboard shortcut stored in the same dot) could suffice, be easier to
manage, and you still could have it do different things depending on the
document you are working on.
(...in the example, trivially, using ActiveDocument.Name in the output
string)

Klaus
 
F

fumei via OfficeKB.com

I agree. Having three separate macros seems over the top. Far better to
have one that identifies the current active document.

BTW: what are you using for context in the key binding instruction?

CustomizationContext = ???????
 

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