run exe program and locate current workbook

D

Domagoj Vulin

I have 2 questions:
1. how can I determine the current working folder of a XLS file with a
macro? GetAbsolutePath didn't give me the best results...
2. is it possible to run .exe program from a VBA macro and how?
 
C

Chip Pearson

Use ThisWorkbook.Path to get the full path name of the workbook.
Use CurDir to get the current default path. You can run an exe
file by using the Shell command. See help for more details.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
K

Keith Willshaw

Domagoj Vulin said:
I have 2 questions:
1. how can I determine the current working folder of a XLS file with a
macro? GetAbsolutePath didn't give me the best results...

What do youmean by this ?

2. is it possible to run .exe program from a VBA macro and how?

Yes , you can use the shell function

Progid = Shell(pathname[,windowstyle])

Progid is a variable of type double and the returns
the process ID if it works or 0 otherwise

pathname - Required String holding the name of the program to execute and
any required arguments or command-line switches; may include directory or
folder and drive.

windowstyle - Optional integer defining style of window in which program
is run , use one of the intrinsic constants

vbHide0
vbNormalFocus
vbMinimizedFocus
vbMaximizedFocus
vbNormalNoFocus
vbMinimizedNoFocus6

Note the program executes asynchronously, that is VBA
does NOT wait for it to complete before carrying on.

Keith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top