1
votes

I have a SAP script in vba. It starts on buttonclick. On my compture, it works fine. But on other computers, after the script is over, and the macro ends with a msgbox(it says Done) the excel file not responding (the script ran fine, saved everything). No error message, moreover it looks like running (in taskmanager). If more excel files are open, cannot change between them. VBA editor is the same. However, there are two excel files - one is the original I opened, and another, that is not visible, only in task manager and named Microsoft Excel - originalfilename. I looked my SAP settings, Excel settings, but couldn't find any discrepancy. Can anyone help, why is it happening?

Thanks!

1
Are you properly closing everything that you may be using for example set x=createobject("Excel.Application") closing the function with set x=nothing? What does the SAP do, could it be doing something still? How many Excel.EXE's are open in the processes tab on task mgr? - Nathan_Sav
Did you forget to reset ScreenUpdating to True? Is it calculating after you set Application.Calculation back to xlAutomatic? - puzzlepiece87
There are no excel events either being triggered? OnChange? Good point on checking calcs and screen updating, could you post the code so we can see? - Nathan_Sav
Thanks the answers, tomorrow I post code.I did not set ScreenUpdating to false, and not set Application.Calculation either. In task mngr on Processes tab two application, with almost the same name (one them has the Microsoft Excel prefix), on Details tab only one Excel.exe. Tha most embarassing, that the file is on network, so I open it, works fine on my PC, but open the exactly same file on another compture - and not so fine... - donmichael
The "other" Excel is probably a modal dialog. If so, sometimes you can [ALT][TAB] to it, sometimes clicking on the "show desktop" icon will allow you to bring it to the front. - david

1 Answers

1
votes

Just been toying with this myself and I just cracked it. In my case I was setting all my objects to nothing but in the wrong order. The reverse order you set them is the key, which is obvious when you think about it.... Hindsight.

Set session = nothing
Set connection = nothing 
Set SapGuiApp = nothing.