run exe program and locate current workbook

  • Thread starter Thread starter Domagoj Vulin
  • Start date Start date
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?
 
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)
 
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
 
Back
Top