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
Are there multiple refreshes in the code? I see you have not set it to refresh synchonously, so a connection might be requested to refresh while a previous one has not yet finished.
ActiveWorkbook.Connections("MYCALL21").Refresh False
- Jean RobertJul 17, 2018Copper Contributor
So first i believe the root cause was actually different, and the issue i reported here is just a secondary effect.
Essentialy, the problem seemed to come from Micro Trends anti virus who was conflicting with my report. I already read similar cases. I asked my IT to "fix" that and now it seems none of the error messages show up anymore, neither those mentionning a vertipaq.xml file in Temp, nor the VBA refresh issues.
- JKPieterseJul 17, 2018Silver ContributorHi Jean,
Glad you got this sorted!