ShellExecute Excel 2010 64-bit doesn't start fresh copy of Excel

jfr92

New Member
Joined
Dec 11, 2013
Messages
13
I have a process that runs all day, gathering data from the web, storing that data on an xlsx file, closing that file, and starting another xlsm book that further process the data while the original process goes back for more collection ( collection of other "parts" of the whole range of data that I gather, hence the reference to 'part' in the code snippet below). Usually I have another unrelated Excel book open in a separate instance of Excel. Say the all-day process is Excel copy 1 and the unrelated work is in 2. When the all-day process uses ShellExecute to start its related function I want and expect that to run in copy 3. Instead, it opens within copy 2 and there are always conflicts between the now unrelated contents of copy 2. Conflicts cause 1004 errors or Excel crashes.

shellexecute Application.hwnd, "open", "C:\users]john\documents\excel\opthistory\histnumber" & part & ".xlsm", vbNullString, vbNullString, SW_HIDE

BTW, I use ShellExecute rather than plain Shell because of the numerous posts about Shell incompatibility with 64-bit. Maybe that conflict can be avoided and Shell would do for me what ShellExecute does not?

Has anyone seen and solved this problem or know how to avoid it?
 
Last edited:

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Why use shell at all, rather than say:
Code:
CreateObject("Excel.Application").workbooks.open "C:\users]john\documents\excel\opthistory\histnumber" & part & ".xlsm"
 
Upvote 0
Rory, thanks, but the reason for wanting to use Shell or ShellExecute is to start a new process that will run in parallel with the main process, thus using more of the machine's processors and running the entire thing in less time. I'm not familiar with the CreateObject method you suggest, but from what I have read I doubt it would accomplish that goal.
 
Upvote 0
OK, well I think that ShellExecute will simply use whatever settings are specified for the relevant file type in the registry, so unless you have xlsm files set to start in a new instance of excel, it won't work. Have you actually tried Shell yet?
 
Upvote 0
Honestly, I don't know how to do Shell in 64-bit. Everything I try for the first time is cribbed from someone else's web posting and I haven't found anyone showing how they did Shell with 64-bit--only postings saying they had tried and failed. As for your comment about the registry, that's the first I've heard about any need or ability to have shellexecute interact with the registry, nor for Excel itself to be able to interact with it in that way.
 
Upvote 0
Using ShellExecute like that is basically like double-clicking a file in Explorer to open it. The registry information for that file type determines what action is taken and how it is performed. You don't have to explicitly interact with the registry in the code.
 
Upvote 0
Rory,

My problem is solved thanks to your suggestion about the registry. When I researched that I found a related discussion of Excel's advanced option to "ignore other programs that use Dynamic Data Exchange (DDE)." Selecting that option caused my calling routine to open the new process in a completely new window. Interestingly, when the called program also has that flag checked it ignores calls from ShellExecute.

Thanks again and happy holidays to you and yours.
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top