Ensure Excel is not running so my Active Data can be correctly opened in a .Net script
If manually closing Excel is not a practical option (for example if scripts are run unattended) then the best approach is to have some code in your script which will check if Excel is running prior to calling the Active Data and if it is, then close it down.
The code below contains a function called IsProcessRunning() which checks if Excel is running and if it is, then kills it. The function should be called from the Public Sub Main() with “Excel” passed in as the process name.
NB. The function “IsProcessRunning()” accepts the string parameter which is the process name
Public Module Main
Dim _desktop As Desktop = Agent.Desktop
Public Sub Main()
Public Function IsProcessRunning(name As String) As Boolean
'here we're going to get a list of all running processes on
For Each clsProcess As Process In Process.GetProcesses()
If clsProcess.ProcessName.StartsWith(name) Then
'process not found, return false