Jump to content
Macro Express Forums

Long delay after launching Excel?


Recommended Posts

When running any one command macro that launches an Excel spreadsheet, such as

Program Launch: "Example.xls" (Normal)
Parameters:

it does so immediately, but there's then a delay of about 5 seconds before the macro stops. Or, if there are other commands, before they are processed.

I'll post in an Excel forum too, but I'd appreciate knowing if anyone else sees similar behaviour please?

I'm using Excel 365 on a Win 10 Pro PC.

 

Terry, East Grinstead, UK

 

 

 

Link to comment
Share on other sites

Check the delay when launching Excel natively.

 

1. Terminate Macro Express.

 

2. Find EXCEL.EXE on the hard drive, and add a shortcut to it on the desktop.

 

3. Edit the Properties of the desktop shortcut. Specify a "Shortcut key." Most function keys are available, but I suggest using two modifier keys + an alphanumeric key, e.g., Ctrl + Alt + E. Click OK.

 

4. Press your new shortcut key, and time how long it takes to launch Excel.

 

Now you can compare the two activation methods -- a Windows-specific technique, and via Macro Express.

Link to comment
Share on other sites

3 hours ago, Cory said:

5 seconds sound normal to me. You're O365. So that means Excel needs to initialize its connection to your cloud storage which usually takes a few seconds.

Thanks Cory but not sure I follow. Excel 365 runs immmediately. It's the MX Pro macro delay I don't understand. Do you have an Excel macro you can try by way of comparison please?

Link to comment
Share on other sites

3 hours ago, acantor said:

Check the delay when launching Excel natively.

 

1. Terminate Macro Express.

 

2. Find EXCEL.EXE on the hard drive, and add a shortcut to it on the desktop.

 

3. Edit the Properties of the desktop shortcut. Specify a "Shortcut key." Most function keys are available, but I suggest using two modifier keys + an alphanumeric key, e.g., Ctrl + Alt + E. Click OK.

 

4. Press your new shortcut key, and time how long it takes to launch Excel.

 

Now you can compare the two activation methods -- a Windows-specific technique, and via Macro Express.

Thanks, but as per my reply to Cory there's no problem with launching Excel - it's immediate as I said in my opening post. By whatever method I use. It's the subsequent delay that I don't understand. As if Excel prevents MX Pro working for that long delay.

 

Link to comment
Share on other sites

To sort of simulate your situation, I ran the following test macro:

Variable Set Integer %N1% from Current Second
Program Launch: "notepad"
Variable Set Integer %N2% from Current Second
Text Box Display: %N1%         %N2% 

The time difference between N1 and N2, over many tests, was almost two seconds.  So I am seeing delays like you describe.  Can't explain it, but yes I see similar behavior to what you see.  You are seeing 5 seconds, I am seeing two, but then I am starting a simpler application.  If I remove the Program Launch command from my test macro, the times displayed are always identical. 

I would guess -- GUESS, mind you -- that ME is being a responsible Windows citizen, asking Windows to launch the application and then waiting patiently for an "all done" acknowledgement from Windows, which is some time in coming.  Sorry, kind of imprecise for a technical answer, but that's the best you will get out of me.:)

Link to comment
Share on other sites

9 hours ago, rberq said:

To sort of simulate your situation, I ran the following test macro:

Variable Set Integer %N1% from Current Second
Program Launch: "notepad"
Variable Set Integer %N2% from Current Second
Text Box Display: %N1%         %N2% 

The time difference between N1 and N2, over many tests, was almost two seconds.  So I am seeing delays like you describe.  Can't explain it, but yes I see similar behavior to what you see.  You are seeing 5 seconds, I am seeing two, but then I am starting a simpler application.  If I remove the Program Launch command from my test macro, the times displayed are always identical. 

I would guess -- GUESS, mind you -- that ME is being a responsible Windows citizen, asking Windows to launch the application and then waiting patiently for an "all done" acknowledgement from Windows, which is some time in coming.  Sorry, kind of imprecise for a technical answer, but that's the best you will get out of me.:)

Many thanks, appreciate your taking the trouble to test.

That could well be the explanation but, if so, it does seem a very generous delay, considering that all that's been done is to open a file.

I have another application, my video editor, Movie Edit Pro, that displays very similar behaviour - but worse, Immediately after it's started, there's a delay of nearly 10 seconds before it will let me even activate any macro!

Link to comment
Share on other sites

When I open Excel it's immediately apparent but then it takes a few seconds before the suggested files and such are made apparent. EG Recent files. When the suggestions appear so too does the links to my OneDrive, SharePoint, et al. This takes 7 seconds on my machine. I believe when starting cold it needs to establish connections to all these web resources. But it's only a guess.

I made a macro to launch the executable. Takes 4-5 seconds or so. If I launch the file name with Excel already open it's 2 seconds. If I launch the file name without Excel open it's 7-8 seconds. I think it just takes Excel some time to initialize. And if you watch the screen and launch excel.exe you can see it takes some time as I described above. Maybe try disabling all your office accounts you're connected to in Excel. 

Link to comment
Share on other sites

Terry,

What happens if you bypass Macro Express's program launching capability, but fool Macro Express into launching the application?

1. Create a desktop shortcut to excel.exe and assign it a shortcut key via its Properties (as described above).

2. Use Macro Express to simulate the shortcut key.

For example, if the shortcut key is Ctrl + Alt + E, the Macro Express Script will be:

Text Type (Simulate Keystrokes): <CONTROL><ALT>e

Are you still seeing delays?

Link to comment
Share on other sites

Or (similar to what Acantor (a singer???) is saying): make a bat file to start Excel; containing just the lines start c:\path\excel.exe and exit

Then  have your macro launch command.com with parameter /c batchfile.bat

Presumably the delay will only be for the time it takes command.com to run -- not long.  Worth a try.

Link to comment
Share on other sites

Thanks both, sorry for delay in replying; away for a while.

Interesting ideas and will try harder later. Meanwhile I had a brief attempt but so far

@acantor, Having trouble assigning a hotkey that works! I have rather few to choose from and thiose I've tried so far either do nothing (there's no feedback) or do something unexpected.

@rberg: Do you mean launch the Command Prompt window? That I can do via Win + X.

Terry, East Grinstead, UK

Link to comment
Share on other sites

Thanks, understood.

That macro got no further than the Command Prompt window.

Typing at the cursor

"C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE"

did then open Excel, although a further 6 seconds elapsed before the hour glass vanished and operations were accessible

I'm no batch expert anyway, and I haven't tried running batch files on this WIn 10 Pro PC until now. But this simple one-line macro,
echo The test works OK
run directly by d-clicking it in its Explorer folder, failed to retain the message (assuming that's what flashed briefly). By adding a second line
echo The test works OK
Pause

the command window stayed open:
https://www.dropbox.com/s/raijri50ftvvfeo/UsingBatchFiles-01.jpg?dl=0
 

And substituting that batch instead of C:\Users\terry\Dropbox\BATCH\Excel-Run.bat
where Excel-Run.bat is
start "C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE"
exit

gave the same correct result, so I'm almost there.

Even so, I'm not sure it will significantly improve access time to Excel.

--------------------

Sun finally out in earnest this morning, so heading off for a 9 mile hike, but will get back on the case asap.

 

Terry, East Grinstead, UK

 

Link to comment
Share on other sites

8 hours ago, terrypin said:

Even so, I'm not sure it will significantly improve access time to Excel.

From your initial post, I thought you wanted the macro to continue sooner after starting Excel -- not have Excel start sooner.  Big difference. 

Link to comment
Share on other sites

Yes, that's what I mean by 'access': MX Pro access to Excel to continue processing commands. IOW, I want to get the macro to do stuff in Excel as close as possible to the speed I can do so manually, including opening Excel and having it ready to work.

Link to comment
Share on other sites

On 2017-05-09 at 3:20 PM, terrypin said:

@acantor, Having trouble assigning a hotkey that works! I have rather few to choose from and thiose I've tried so far either do nothing (there's no feedback) or do something unexpected.

About 1000 key combinations are available, so keep trying!

Most function keys are available, as are many keys on the numeric keypad. But the safest combos are Ctrl + Shift + Alt + something. Few programs require a user to press and hold three modifiers at the same time. Other combos you can use are Ctrl + Alt + something, Shift + Alt + something, and Ctrl + Shift + something.

If the shortcut key can be assigned, it will instantly appear in the field as you press that key combination.

Shortcut keys.jpg

Link to comment
Share on other sites

I'd say my initial estimate of 5 seconds was too short. The following macro, which opens a specific workbook in Excel 365, cannot continue processing for at least 8 seconds after activation. The file is loaded very quickly, but as rberg suggested in his 30th April post MX Pro then waits a long time.

Program Launch: "20160724-Day03-Hoops-Clovelly-J-e570-m6.6.xlsm"" (Normal)
Parameters: 
Text Box Display: Test
// It takes about 8 seconds before text box appears. IOW, before macro can continue.

 

However, the good news is that if instead I use the Run box, as shown in the following macro, it can continue in about 2-3 seconds:

Text Type (Simulate Keystrokes): <WIN>r
Delay: 0.1 seconds
Text Type (Simulate Keystrokes): excel.exe "C:\Users\terry\Dropbox\FinishedWalks\20160724-Day03-Hoops-Clovelly-J-e570-m6.6.xlsm"
Delay: 0.1 seconds
Text Type (Simulate Keystrokes): <ENTER>
Delay: 0.5 seconds
Wait for Window Title: xlsm - Excel // DISABLED. If included, the delay increases dramatically to a duration like the basic method.
Text Box Display: Test

 

I should have tried that approach earlier, especially as I've used it before for program launching. The article referenced in Cory's post yesterday reminded me about it.

Note my comment about the negative effect of using the more logical command Wait for Window Title instead of a (trial/error) 0.5 s Delay.

Terry, East Grinstead, UK

Link to comment
Share on other sites

3 hours ago, Cory said:

Have you tried launching excel.exe with the command line parameter containing the file name? I doubt it will make any difference. 

No change, still 8 secs before the TBD appears.

Terry, East Grinstead, UK

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