Load XML into Excel through VBA

后端 未结 2 429
难免孤独
难免孤独 2020-12-15 10:49

I\'ve got a bit of VBA that is loading an XML file through VBA. However when it is imported it is all in one column and not split into a table.

When I manually impo

2条回答
  •  攒了一身酷
    2020-12-15 11:50

    I used a few sections from other sections of code I've found. The below code will prompt the user to select the XML file you want and allows them to simply add/import the selected file into their existing mapping without opening a new file.

    Sub Import_XML()
    '
    ' Import_XML Macro
    '
        'Select the file
        Fname = Application.GetOpenFilename(FileFilter:="xml files (*.xml), *.xml", MultiSelect:=False)
    
        'Check if file selected
        If Fname = False Then
            Exit Sub
            Else
    
        End If
    
        'Import selected XML file into existing, custom mapping
    
        Range("B5").Select
        ActiveWorkbook.XmlMaps("Result_file_Map").Import URL:=Fname
    End Sub
    

提交回复
热议问题