I'm decided to try my way around VBA, got a little script running to export a XML map I have in a worksheet to XML, works fine so far, but when that XML file is already generated, it returns a error instead of replace it... I tried many ways I've seen in other topics of this forum and around web but because I don't know VBA protocols it's taking me (a lot) of time, can anyone help?
What I have so far:
Sub Export_Main_XML()
Dim JobNumber As String
JobNumber = Sheet12.Range("A4").Text
XMLName = ThisWorkbook.Path & "\" & JobNumber & "_Main_Export.xml"
ActiveWorkbook.XmlMaps("Main_XML_Map").Export URL:=XMLName
End Sub
Ideally what I'm looking for is:
Export
-if not file existent, just export (script above)
-if file on same path and name exists > ask to replace "yes or no"
-if yes, replace
-if no, exit
Help please, Thanks!