ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   run exe program and locate current workbook (https://www.excelbanter.com/excel-programming/272012-run-exe-program-locate-current-workbook.html)

Domagoj Vulin

run exe program and locate current workbook
 
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?



Chip Pearson

run exe program and locate current workbook
 
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



"Domagoj Vulin" wrote in message
...
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?





Keith Willshaw

run exe program and locate current workbook
 

"Domagoj Vulin" wrote in message
...
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




All times are GMT +1. The time now is 04:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com