Jump to content
Macro Express Forums

Scopes


Recommended Posts

I would like to have different macros on the same hotkeys for one special word-document. Those hotkeys are already assigned as program specific macros (winword.exe)

 

If i code a windowspecific macro (window is a word document) this macro is just ignored. I thought that it would kind of override the standard word-specific macro because it´s assigned to a special windowtitle. But it´s just not working.

 

So how can i assign a different macro to a windowtitle although the hotkey is already assigned to a program. Is this not possible?

 

(Checking in every programspecific macro for the current windowtitle is not an option)

 

Thank You

Alex

Link to comment
Share on other sites

You may need to change the activation of the original macro from program specific to window specific. If you can contrive things so that the two window titles are unique, things should work.

 

Another alternative is to use one Word-specific macro, and then test for different window titles...

 

Variable Set String %WindowTitle% to topmost window title
Switch( %WindowTitle% )
Case: Document 1 - Microsoft Word
// Do this
End Case
Case: Test document - Microsoft Word
// Do that
End Case
Default Case
// Do something else...
End Case
End Switch

Link to comment
Share on other sites

Thanks Alan,

 

but those two solutions are the ones i want to avoid. First one isn´t actually a solution as i would loose the wordspecificness (all wordfunctionality) if i would assign the macros to a windowtitle instead of winword.exe. I don´t know all the windowtitles of my word-documents by now, or?

 

It is hard to believe that nobody thought of a scopefunction like program except. Logically MEX should choose the window specific (more special) macro if a program specific and a window specific scope matches. So in cases of conflicts that would mean title for program for global. That would make sense, no?

 

Thank You

Alexandra

Link to comment
Share on other sites

Try changing the program-specific macro to window-specific. By setting it to "- Microsoft Word", the macro will be recognized in all Word documents. (Every Word file has this text fragment in their title bar.)

 

Then, you can perform different actions in different windows, depending on the titles. Here is one way:

 

Variable Set String %WindowTitle% to topmost window title

If Variable %WindowTitle% Contains "ABC"
// Do this...
Else
 If Variable %WindowTitle% Contains "XYZ"
 // Do that...
 End If
End If

Link to comment
Share on other sites

Where is the difference by setting it to "- Microsoft Word" compared to setting it to program specific to winword.exe?

 

NONE! I still would have to differentiate within the macro. But for now this seems to be the only workaround. It´s a shame this whole scope concept lacks a little logical hierachy.

 

Alex

Link to comment
Share on other sites

Where is the difference by setting it to "- Microsoft Word" compared to setting it to program specific to winword.exe?

 

One difference is that a macro scoped to winword.exe will be triggered when a Word dialog box is open and focused, or Word is open but no documents are displayed. A macro scoped to "- Microsoft Word" (partial match) will only be triggered if a Word document is open; nothing will happen when a Word dialog box is focused, or Word is open but all document windows are closed.

Link to comment
Share on other sites

Alan,

 

thats right. But i usally don´t write macros for dialog boxes. For my problem as i stated it makes no difference.

 

Thank you anyway. If anyone knows how to write program except macros without the need to reprogram the program specific ones i would be happy to know.

 

Thank You

Alexandra

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...