Forum Discussion
VBA Refresh Connections : Error 1004 Application-defined or object-defined error
Hi JKP ! I'm honored to have you read my post, i've used your precious help a lot in the past.
In reality, I'm pretty sure the code is not really the problem, since it worked for 6-7 years with no issues. And again, it just stops on the line of code, and if i hit F8 it continues with no issue.
I believe the problem is inherent to Windows, or a conflicting app, or update. Moreover, some users dont run into the error message, while others do. Still, here the code (that includes SQL statements, confidential so I have to hide the details).
Sometimes also, Excel just freezes ('Not Responding') and doesnt finish the code.
Sometimes also, Excel closes completely without any warning.
And also, sometimes there is an error message mentionning the Temp folder, as such : "
We couldn't refresh multiple table including … the following error occurred while opening the file … xxx.162.cub.xml … the requested operation cannot be performed on a file with a user-mapped section open."
The code as it stops on the last line (Refresh):
With ActiveWorkbook.Connections("MYCALL21").OLEDBConnection (...) With ActiveWorkbook.Connections("MYCALL21") .Name = "MYCALL21" .Description = "" End With ActiveWorkbook.Connections("MYCALL21").Refresh