Can anyone look at the code below and give me some suggestions on why it would leave an excel.exe process running?
Code:
Dim OutPutFileName As String
strPath = "C:\temp\test.xlsb"
Set ApXL = CreateObject("Excel.Application")
Set xlWBk = ApXL.Workbooks.Open(strPath)
ApXL.Visible = False
iRowCountA = Range(xlWBk.Sheets("sheet1").Range("A2"), xlWBk.Sheets("sheet1").Range("A2").End(xlDown)).Rows.Count
ApXL.Visible = True
OutPutFileName = "C:\temp\test- " & Format(Now, "yyyymmdd hhmmss") & ".xlsb"
xlWBk.SaveAs FileName:=OutPutFileName
Set xlWBk = Nothing
Set ApXL = Nothing
I have removed some other code but I know the line that starts with "iRowCountA......" is the culprit. If I comment it out that line there is no issues.
Thanks in advance.