Excel External Data Connection crashing on other users

1k Views Asked by At

I have a tool.xlsx file that uses external data connection to Access DB (both are on a network drive, available to users with proper access rights). I have a vbscript (code below) that refreshes all the connections in that workbook. Everything works like charm when I am running this script but when a colleague runs it, it throws no errors but not all the connections are refreshed. Any ideas?

Dim XLApp
Dim XLWkb
Set XLApp = CreateObject("Excel.Application")
xlapp.visible = false
xlapp.workbooks.open "\\networkpath\tool.xlsx"
xlapp.displayalerts = false
set wr = xlapp.workbooks.Open("\\networkpath\tool.xlsx")
wr.refreshall
xlapp.visible = false
wr.Save
wr.Close

And here is the connection string from that tool.xlsx workbook:

Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=\\networkpath\db.accdb;Mode=Share Deny Write;Extended Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Engine Type=6;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False;Jet OLEDB:Bypass UserInfo Validation=False;Jet OLEDB:Limited DB Caching=False;Jet OLEDB:Bypass ChoiceField Validation=False

Here's a different approach at refreshing each connection at once:

on error resume next
Dim XLApp
Dim XLWkb
Set XLApp = CreateObject("Excel.Application")
xlapp.visible = false
xlapp.displayalerts = false
set wr = xlapp.workbooks.open("\\networkpath\tool.xlsx")
    for each Cn in wr.Connections
        Cn.Refresh
    next
wr.refreshall
xlapp.visible = false
wr.Save
wr.Close
0

There are 0 best solutions below