Excel VBA Code required to access other applications

xsdip

New Member
Joined
May 21, 2019
Messages
32
Hi Everyone.

Could you please help me on this.

I am looking to create a VBA code, to open an application (Not Microsoft apps) and to access Tools-Play Macro-Select a textfile from the dialogue box opened.
This textfile has some macros which is compatable with the opened application. Once this textfile is selected by user, it will run a code automatically.

After the execution, I want to close the application also using the vba code.

In between, when we open the application, it would ask for working directory of the application, which will be selected by user itself.

could anyone please help me on creating the same?
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Is it a good option to try with Send keys? But sometimes it does not work.

Could anyone help me on this please..
 
Upvote 0
Unless the application is compatible with COM automation, SendKeys (or equivalent API calls) will probably be your only option in VBA. Power Automate might be a better bet unless it has to be VBA.
 
Upvote 0
Here is an example using a function to add time delay and then using Shell to open the calculator and simulating pressing different keys with the time.

VBA Code:
Function WaitTime(ByVal milliSeconds As Double)
Application.Wait (Now() + milliSeconds / 24 / 60 / 60 / 100)

End Function

Sub SendKeyExample()
'Using shell command to open the calculator
filepath = Shell("Calc.exe", vbNormalFocus)
'Using the function to wait
WaitTime (1000)
'Using various sendKeys to simulate touching 64 the plus sign and then 81 and finally the EnterKey
Call SendKeys("64", True)
Call SendKeys("{+}", True)
Call SendKeys("81", True)
Call SendKeys("{Enter}", True)

End Sub
On place to get a list of sendkeys can be found here: Application.SendKeys method (Excel)
 
Upvote 0
Thanks Trevor. That was very helpful..

I just have a doubt. When I open this application, I need to select working directory.
So would it be possible to select the working directory during the execution of the VBA macro?
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,118
Members
453,021
Latest member
Justyna P

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