VBA Export XmlMap and navigate where to save as.

Addictions

Board Regular
Joined
May 27, 2018
Messages
60
Office Version
  1. 365
Hello,

I am trying to figure out how to export XmlMap with a prompt to navigate where to save as.
Currently I have a code which exports XmlMap but to the file path and I would like to navigate where to save it as.
Can you help please?.

VBA Code:
Sub ExportAsXMLData()
 Dim objMapToExport As XmlMap
 
 Set objMapToExport = ActiveWorkbook.XmlMaps("Customer")
 
 If objMapToExport.IsExportable Then
 
 ActiveWorkbook.SaveAsXMLData "Customer Data.xml", objMapToExport
 Else
 MsgBox "Cannot use " & objMapToExport.Name & _
 "to export the contents of the worksheet to XML data."
 End If
End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I can only find a way to add a hard path in to the code. I am sure there must be a way for a prompt where to save it.
 
Upvote 0
Replace the Save line with:
VBA Code:
        Dim XMLfullName As Variant
        XMLfullName = Application.GetSaveAsFilename(InitialFileName:="Customer Data.xml", FileFilter:="XML Files (*.xml), *.xml", Title:="Save XML Data")
        
        If XMLfullName <> False Then
            ActiveWorkbook.SaveAsXMLData XMLfullName, objMapToExport
            MsgBox "Saved " & XMLfullName
        Else
            MsgBox "User cancelled - not saved"
        End If
 
Upvote 0
Haha, happens to all of us.

Works amazing! You are a genius. Thanks for the help. Much appreciated!
 
Upvote 0

Forum statistics

Threads
1,214,801
Messages
6,121,644
Members
449,045
Latest member
Marcus05

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