PDA

View Full Version : Solved: Embed and Extract .exe



aerodoc
10-24-2010, 10:13 PM
Is there a way to embed an file (exectuable in this case) such that when a macro is activated, the .exe gets copied to a certain directory?

I would like to do this since the Excel file passes data to and from the executable and it would be nice if everything was self contained. So the user would first unpack the .exe and then run the Excel file.

xld
10-25-2010, 12:25 AM
I would suggest using an installer, such as Inno Setup (http://www.jrsoftware.org/isinfo.php), to install that exceutable in the target directory.

aerodoc
10-25-2010, 07:59 AM
I could do something like that, thanks for point it out. I can also do a self extracting zip file as well, to keep it simpler.

But I was curious about embedding it because then the user could share the Excel file with anyone and then it could be unpacked on any computer, without the need for a separate installation. I thought this would be convenient for the user, but there may not be a simple (or even any) way to do this?

Kenneth Hobs
10-25-2010, 04:52 PM
Depends on what the EXE is and does:

After you embed the object:
ActiveSheet.OLEObjects("Object 1").Verb xlPrimary

You can use Dir() to determine if the EXE file or folder exists if needed.

aerodoc
10-27-2010, 10:32 AM
Ken,

Thanks again, just got around to trying this out and it works. Do you know of any scenarios where it might fail to work? (i.e. OLE requirements/restrictions). I don't know much (understatement) about OLE objects.

Kenneth Hobs
10-27-2010, 04:53 PM
It depends on what the EXE does I would imagine. Most likely, if it worked in testing, it would work for most.