I don’t see why this doesn’t work.
I have gone into the registry and removed the registry key below and still no joy. The error arises at the For Each Loop. If anyone could help it would be appreciated.
I am using .net framework 1.1
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance\Disable performance counters
If System.IO.File.Exists(path) Then
System.IO.File.Delete(path)
ExcelApp.DisplayAlerts = False
ExcelApp.ActiveWorkbook.SaveAs(path)
ExcelApp.DisplayAlerts = True
ExcelApp.Quit()
MessageBox.Show("File Exported to: " & path)
Dim proc As System.Diagnostics.Process
For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
'Debug.Print(Now() & " - Killing process ID " & proc.Id)
proc.Kill()
Next
Else
'saves the file
ExcelApp.DisplayAlerts = False
ExcelApp.ActiveWorkbook.SaveAs(path)
ExcelApp.DisplayAlerts = True
ExcelApp.Quit()
Dim proc As System.Diagnostics.Process
For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
'Debug.Print(Now() & " - Killing process ID " & proc.Id)
proc.Kill()
I think this might be a permission issue.
Take a look at Here and Here