VBA code - Export to xml and save as name from excel cell

Donbozone

New Member
Joined
Mar 28, 2020
Messages
45
Office Version
  1. 365
Platform
  1. Windows
Ok, not completely clear from thread name what I'm exactly trying to do, but I'm gonna try to explain.

In my workbook I have sheet1 which contains my table with some 2000+ rows. This is my data source.
On sheet two I have something like form which is already mapped with an xml schema and can be exported (right click/xml/export or developer tab/xml/eport).

What I need is to create as many xml files as there is rows in my source table. I need to copy from source only one cell, let say from A1 to my form and all other fields will be filled based on that value (added by xlookup).

What VBA code suppose to do is:

  1. Copy from A1 (source table) to lets say A1 (form sheet)
  2. Export form to xml
  3. Save as xml to the specific folder under specific name
  4. Copy from A2...and so on to the last row
For point 3, I would add folder path in one column in source table and for xml file name I would add another one, so basically all information that I need could be found in one row of my source data.

I would appreciate if someone has some solution.

Thanks,
Bozo
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I have made something like this, but it does not work:



Sub ExportToXml_2()



Dim i As Long, LastRow As Long

Dim path As String

Dim file As String

Dim sh As Worksheet



LastRow = Worksheets("sheet1").Range("AS2000").End(xlUp).Row


For i = 4 To LastRow

Set sh = ActiveSheet

sh.Range("F2").Value = Worksheets("sheet1").Range("A" & i).Value


file = sh.Range("I3").Value

path = sh.Range("I2").Value



Dim objMapToExport As XmlMap

Set objMapToExport = ActiveWorkbook.XmlMaps("Mapname_Map")



If objMapToExport.IsExportable Then

ActiveWorkbook.SaveAsXMLData path & "\" & file, objMapToExport

Else

MsgBox "Neodgovarajuća šema za eksport XML " & objMapToExport.Name

End If

Next i

End Sub

Im obvoiusly missing something...
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,269
Members
449,075
Latest member
staticfluids

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