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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Are you actually changing the source path, or just trying to refresh the map in Excel?
 
Upvote 0
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."?
 
Upvote 0
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?
 
Upvote 0
Yes, as far as I am aware. Do let me know if the problem happens again though.
 
Upvote 0

Forum statistics

Threads
1,213,567
Messages
6,114,344
Members
448,570
Latest member
rik81h

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
Back
Top