Jump to content
Macro Express Forums

Activate Excel not always successful


pblomfield

Recommended Posts

I have several macros that switch from an application to an Excel spreadsheet, copy data and then switch back to the application to paste the data.

 

I use, for example, <ACTIVATE2:CREDIT CARD TRANSACTIONS .xlsx>

 

Usually this works OK but occasionally the macros do not switch to Excel. The Excel tab at the bottom of the screen will wink orange a couple of times and then stays orange.

 

Anyone any ideas why and how to stop this happening?

Link to comment
Share on other sites

It sounds like Excel is trying to get your attention because it is trying to get focus but is being held back by another application. The general idea of the flashing is not to steal focus from the foreground application (behaviour set in registry, HKEY_CURRENT_USER\Control Panel\Desktop, ForegroundFlashCount). Only you can see what else is running - the application you mentioned plus whatever. The other application may be hanging things up a bit.

 

When you activate Excel you could add a delay of say 1 sec (trial and error) then activate again. Alternatively put in a loop that checks if Excel is focused and if not, make it so (Jean Luc Picard's words, not mine!)

 

(edit) Another aspect could be that when copying data, you are trying to activate Excel too soon. Large amounts of data take time to copy to the Clipboard. You should allow a time delay before the activation. I use anywhere from 10mS to 2secs.

Edited by JohnS
Link to comment
Share on other sites

  • 2 weeks later...

John,

 

Thanks for the help , much appreciated. I still haven't solved the prob but I haven't been able to try all your suggestions yet. I've made sure nothing else is running and 9 times out of 10 it runs Ok. Then, just when I'm thinking we've cracked it it hangs. I'll try playing with delays and see if there's any improvement.

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...