VBA: Update the source of an XML Map and refresh

Ferdi24

Board Regular
Joined
Feb 26, 2012
Messages
133
Hi, I have an XML map and I need to update the source and refresh.
The result is currently in a table. I usesd developer > source > XML Maps > Add and then dragged the elements into the sheet to create a table.

How do I do this via VBA? All the elements will be exactly the same.

So far I've tried
Code:
mYQuery = "http://example.myxml.com/feed.aspx?id=12
ThisWorkbook.XmlMaps("MyMap").Import (myQuery)
But this does not work properly. It updates some parts of the new data, but not all of it for some reason.

I have also tried
Code:
ActiveWorkbook.XmlMaps("MyMap").Delete
ActiveWorkbook.XmlMaps.Add(mQuery, "search").Name = "MyMap"
But then all the elements are not mapped and I don't know how to add the to the table.

Thanks for you help!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,696
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Are you actually changing the source path, or just trying to refresh the map in Excel?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,696
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
OK. Can you give an example of what you meant by "It updates some parts of the new data, but not all of it for some reason."?
 

Ferdi24

Board Regular
Joined
Feb 26, 2012
Messages
133
Hi rorya,

I was just about to copy an example but now it works.
It might have been a temporary issue, but usually I don't believe in temporary issue. Logic is logic.
So would you confirm that generally
Code:
ThisWorkbook.XmlMaps("MyMap").Import (myQuery)
is the correct code to update the source of an XML map?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,696
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Yes, as far as I am aware. Do let me know if the problem happens again though.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,553
Messages
5,636,989
Members
416,953
Latest member
broexc

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top