Sub Create_XSD()
Dim StrMyXml As String, MyMap As XmlMap
Dim StrMySchema As String
StrMyXml = "< BookInfo >"
StrMyXml = StrMyXml & "<Book>"
StrMyXml = StrMyXml & "<ISBN>Text</ISBN>"
StrMyXml = StrMyXml & "<Title>Text</Title>"
StrMyXml = StrMyXml & "<Author>Text</Author>"
StrMyXml = StrMyXml & "<Quantity>999</Quantity>"
StrMyXml = StrMyXml & "</Book>"
StrMyXml = StrMyXml & "<Book></Book>"
StrMyXml = StrMyXml & "</ BookInfo >"
' Turn off async loading.
Application.DisplayAlerts = False
' Add the string to the XmlMaps collection.
Set MyMap = ThisWorkbook.XmlMaps.add(StrMyXml)
Application.DisplayAlerts = True
' Create an empty file and output the schema.
StrMySchema = ThisWorkbook.XmlMaps(1).Schemas(1).XML
Open "C:\MySchema.xsd" For Output As #1
Print #1, StrMySchema
Close #1
End Sub