Get Process ID of SOLIDWORKS Session Example (VBA)
This example shows how to get and verify the process ID of the current
SOLIDWORKS session.
'--------------------------------------------------------
' Preconditions:
' 1. One SOLIDWORKS session is running.
' 2. Open the Immediate window.
'
' Postconditions:
' 1. The process ID of the SOLIDWORKS session is
' printed to the Immediate window.
' 2. To verify, open a Command Prompt window, type TASKLIST, and
' locate sldworks.exe in the Image Name column and its
' process ID in the corresponding PID column.
' 3. Exit the Command Prompt window.
'----------------------------------------------------------
Dim swApp As SldWorks.SldWorks
Sub main()
Set swApp = Application.SldWorks
' Print the current SOLIDWORKS session's PID to the
' Immediate window
Debug.Print "SOLIDWORKS process ID: " & swApp.GetProcessID
End Sub