Hello
I have a really strange problem with my excel web API query connection. It is suppose to download a file from API and it works really fine. However it should only do so when i click a button "Download". For this button i created a simple vba for a refresh:
I also have a different button to refresh all other queries in my workbook. It has exact same vba code but of course with different query names and not including the one i mentioned above.
Now, when I open my excel file and click a button to refresh all other queries, the query "Query - Test" doesnt get refreshed and its ok. HOWEVER when queries finish refreshing, I still get a pop-up window to download this file, despite a query has not been refreshed! What makes it even more strange is that it happen ONLY when i click the refresh button for the first time. It never does it again unless I close and open my excel file again.
I put following vba code in modules to disable any possible refresh:
... but I still get a download pop-up when i refresh the other connections for the first time... Is there any way i can prevent this happening?
Alex
I have a really strange problem with my excel web API query connection. It is suppose to download a file from API and it works really fine. However it should only do so when i click a button "Download". For this button i created a simple vba for a refresh:
VBA Code:
Public Sub CommandButton2_Click()
Application.DisplayAlerts = False
ThisWorkbook.Queries.FastCombine = True
ThisWorkbook.Connections("Query - Test").Refresh
End Sub
I also have a different button to refresh all other queries in my workbook. It has exact same vba code but of course with different query names and not including the one i mentioned above.
Now, when I open my excel file and click a button to refresh all other queries, the query "Query - Test" doesnt get refreshed and its ok. HOWEVER when queries finish refreshing, I still get a pop-up window to download this file, despite a query has not been refreshed! What makes it even more strange is that it happen ONLY when i click the refresh button for the first time. It never does it again unless I close and open my excel file again.
I put following vba code in modules to disable any possible refresh:
VBA Code:
Public Sub disableAutoRefreshConnection()
Dim cnn As WorkbookConnection
For Each cnn In ActiveWorkbook.Connections
With cnn.OLEDBConnection
.BackgroundQuery = False
If .Refreshing Then .CancelRefresh
.EnableRefresh = False
.RefreshOnFileOpen = False
.RefreshPeriod = 0
End With
Next
End Sub
... but I still get a download pop-up when i refresh the other connections for the first time... Is there any way i can prevent this happening?
Alex