Jump to content
Macro Express Forums

Scope fails to see the current "on top" Pgrm


Recommended Posts

I've created a couple of macros with EXCEL.EXE set as the scope.

 

One of the macros is working but the other one is misbehaving so I decided to edit it.

 

I went to the offending macro and clicked the edit tab and got "The program must be on top".  But the program is on top.  

 

The only thing I've done recently is move the program file from the desktop to a  subfolder in My Documents. could that be causing this?  I actually moved it back after this error message but that didn't stop the error.

 

 

On Top.jpg

Link to post
Share on other sites

Have you confirmed your script is failing to trigger? One way to check is to insert a line at the start of the script that pops a message box.

 

What happens if you do a test run within Macro Express? Or if you run the script line by line?

 

Try changing the scope to Global. Then test in Excel. If the script works as expected, set the scope back to program-specific.

 

Alternatively, set the scope to (partial) window-specific, e.g.,  " - Microsoft Excel."

 

If these suggestions do not help, re-create the script from scratch. Occasionally, a Macro Express script becomes unsalvageable. It doesn't happen often, but it may not be worth the effort to figure out what's actually gone wrong. The source of the problem may be the logic of the script, variable name confusion, or whatever.

Link to post
Share on other sites
Quote

Have you confirmed your script is failing to trigger? One way to check is to insert a line at the start of the script that pops a message box

I think it's safe to say that both macros I created with XL as Scope are being triggered because when I press the shortcut keys both macros run, except that one misbehaves, and that's the one I need to look at. 
Quote

What happens if you do a test run within Macro Express? Or if you run the script line by line?

I get the same results inside MacroX but I've only just started using MacroX and have little experience running line by line, although I am familiar with the concept have used the F8 step option with XL macros.  It just doesn't seem to behave the same way so I may be doing something wrong.  I read up on the process in MacroX

 

Quote

Try changing the scope to Global. Then test in Excel. If the script works as expected, set the scope back to program-specifiTc.

I considered doing that but it wouldn't answer the question as to why it stopped allowing me to Edit the macro with the XL scope set. I'd was also about to simply delete the macro and create a new one when I clicked the edit option and it opened in Edit mode!  Don't know what happened to cause that.  

 

Bottom line, I guess I'll never know why it was getting the error but if it happens again I let you know.

 

Thanks for your help with this.

 
Link to post
Share on other sites
This was working moments ago. 
 
I've been editing code, and running it, trying to figure out why it won't continue after the Wait command. 
 
Then I started getting the Scope error, again.  Then the Ctrl-P shortcut stopped working and I started getting the XL editor's 'assigned" shortcut.  MacroX had indicated it was not assigned, and, as I indicated, it had been working.  So I changed the shortcut, using Ctrl-Alt combinations and none of them worked.
 
I tried to run the other macro with the XL scope and it still works fine.
 
When I run line by line the text no longer appears (but I believe that should be expected) but the Caps Locks switches on then off as I step through the code.  I'm not sure how to handle the Wait line as F7 stops when I get to it.  But if I Lt click the mouse I get a context menu, which I clear and F7 steps me to the next line.
 
I'm guessing no text will appear in the XL editor when I'm running line by line.  How do I test those lines?  If I change the scope to a text editor wouldn't I have the same problem?
 
So. 1. Why do I continue to have this Scope problem with the MacroX editor?
  1. How do I write a wait option that continues after I enter the set parameter; like a key or mouse click?
At this point I plan to create a new macro, with a different shortcut and using this same code, to see if it will run.
 
ps I did that and it ran, but I had the, expected, Wait problem so went in for an edit and got the Scope error again!  I have the Scope set to Exel.exe and the XL program is open with the Editor as the active window.
 
Why am I able to edit for a while then not get this error.  Except in this case I got the Scope error the first time.
 

XL3.jpg

XL2.jpg

xl 1.jpg

Link to post
Share on other sites

Is there any way to get some response to this f/u question? 

 

Is it possible for a question to get lost in the shuffle like if someone responds once, forcing it down the list,  or has it been looked a lot since my last response and no one has an answer?

Link to post
Share on other sites
  • 1 month later...

If you have a new issue, try making a new post and referring back to this one if relevant.

Sorry I don't have time to digest your entire port. It seems too convoluted and complex for me to have the time to answer right now. 

BTW, I live in Fallbrook. 🙂

Link to post
Share on other sites

Your script may be more complicated than necessary, so you may be seeing side effects of the complexity.

 

Try this simplified version, which does something similar:

 

Text Type (Simulate Keystrokes): <F2> // Edit cell
Text Type (Simulate Keystrokes): Range("") // Insert formula
Text Type (Simulate Keystrokes): <ARROW LEFT><ARROW LEFT> // Move cursor back to between quote marks
<TEXT TYPE Action="0" Text="<F2>" _COMMENT="Edit cell"/>
<TEXT TYPE Action="0" Text="Range(\"\")" _COMMENT="Insert formula"/>
<TEXT TYPE Action="0" Text="<ARROW LEFT><ARROW LEFT>" _COMMENT="Move cursor back to between quote marks"/>

 

Link to post
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...