

IntError = objProcess.Terminate 'Terminates a process and all of its threads. Set objList = objWMIcimv2.ExecQuery("select * from win32_process where name='" & strTerminateThis & "'") Set objWMIcimv2 = GetObject("winmgmts:!\\.\root\cimv2") StrTerminateThis = " bc-wedge.exe " 'Connect to CIMV2 Namespace and then find the. 'Process to terminate – you could specify and. ' then terminates ALL instances of the exe process held in the variable strTerminateThis.ĭim strTerminateThis As String 'The variable to hold the process to terminateĭim objWMIcimv2 As Object, objProcess As Object, objList As Object ' Uses WMI (Windows Management Instrumentation) to query all running processes To change the program to TCP-Com, TCP-File, COM-File or any other application, simply change the name of the exe. Our WinWedge example can be found at the bottom of the Launching WinWedge from an Excel Macro support article.

For other applications, such as WinWedge or B-Coder, there is a much easier method facilitated by DDE (Dynamic Data Exchange). We recommend using this method if you are using BC-Wedge, TCP-Com, COM-File or TCP-File. This can be used for both our applications or any other windows program. Path = " C:\Program Files\BC-Wedge\BC-Wedge.exe"Ĭlosing any application from VBA can be accomplished with the example code below.


' Set the Path variable equal to the path of your program's installation Your path will also be different if you installed BC-Wedge in a location other than default or if you are trying to open a program other than BC-Wedge. Note that if you are running on a 64-bit machine, your path will be different. The example below is configured for the BC-Wedge installation on our Windows 7 machine. It can easily be used to open up any Windows program. Visual Basic for Applications (VBA) is part of all Microsoft Office products, including Excel, Access, Word, and more.
