1

I'm using Excel 2010 to link a table to a XML file on my server. I'd like to distribute the Excel file to a group of people and have it updated every time the XML file is updated on the server.

In Excel, I'm pulling the data using "Data", "From Web" and then I type in the path of the XML file.

Excel then builds a table with all the data but if the XML file is updated on the server, the data remains static, even if I click "Refresh" or "Refresh XML data" on the table.

It should be able to download new data including new columns to the table, if any.

Is there a way to do this?

1 Answer 1

2

I am not an expert in VBA , here what I will do 1. Refreshing when opening an Excel file , That can be done by

Sub RefreshData()
    ActiveWorkbook.RefreshAll
' or you can give specific workbook and worksheet identification
End Sub

Private Sub Workbook_Open()
'Call Refresh Data Subroutine when opening file
RefreshData

end sub 
  1. You can use worksheet activate event handler if you have multiple worksheet in a file.

    Private Sub Worksheet_Activate()
    'Call Refresh Data Subroutine when opening file RefreshData
    End Sub

  2. Updating MSexcel as soon as server gets update , doesn't make sense as data will be available for view only after file gets open , however if your macro is been used for live monitoring and kept open 24 hours then instead of sending a event from server and catching in VBA , I suggest implement polling every day/hour/minute/second ( call refresh at poll interval) depending upon your refresh requirement criticality.

    Dim TimeToRun

    Sub auto_open() Call Schedulerefresh End Sub

    Sub Schedulerefersh() TimeToRun = Now + TimeValue("00:00:10")

    Application.OnTime TimeToRun, "XMLRefersh"
    

    End Sub

    Sub XMLRefresh()

    'Call Refresh Data Subroutine when opening file RefreshData Call ScheduleRefresh End Sub

    Sub auto_close() On Error Resume Next Application.OnTime TimeToRun, "XMLRefresh", , False End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.