XML Map - Set path to dynamic

  • Thread starter Thread starter Grant
  • Start date Start date
G

Grant

Hi all,

I import XML data into a worksheet, and choose a mapping
name, but I have no idea how to change the path so that
it is dynamic.

I've been trying to find a way to set my mapping paths to
dynamic, so that when I move the folder that contains the
xl file and xml files, the mapping path still works.

Help :)

Cheers,

Grant.
 
I'm not sure you can make it 'dynamic' per se but you can write code to
change. Here's a sample of changing the bound xml document.

ActiveWorkbook.XmlMaps(1).DataBinding.LoadSettings ("C:\Services
Proposal.xml")
 
Hi Charles,

Thanks for your reply.

I wrote some code in the workbook open event to
dynamically set the databinding for each xml map in the
workbook, but can only set it up if the actual xml files
are in the same directory as the xl file. i.e. I can't
seem to workout how to work with xml files in sub folders
and folders that don't even belong in the base directory
or sub directories :(

My code (that works if the xml files are in the same
folder as the xl file) is:

========================================

Private Sub Workbook_Open()
Dim objXmlMap As XmlMap, s As String, i As Integer, n
As Integer

For Each objXmlMap In ActiveWorkbook.XmlMaps
s = objXmlMap.DataBinding

For i = 1 To Len(s)
If Mid(s, i, 1) = "\" Then n = i
Next

objXmlMap.DataBinding.LoadSettings
(ActiveWorkbook.Path & "\" & Mid(s, n + 1, Len(s) - n))
Next
End Sub

========================================

Oh, I wish Microsoft would allow dynamic binding with xml
documents - it makes complete sense to have this
functionality, and complete nonsense (to me anyway) to
not have it.

Oh well... I'll keep trying to sort out some other way.

Thanks again.

Grant.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top