Hello. I need to write a macro on VBA, which will open the XML file through FileDialog, start the User form, where the user will select the element whose content will be written to the XLS file. I kind of figured out the Userform and the opening of the file. But I'm having problems with the XPATH request. Code:

Sub subReadXMLStream() Dim dlg As FileDialog Set dlg = Application.FileDialog(msoFileDialogOpen) If dlg.Show Then Open dlg.SelectedItems(1) For Random As #1 End If UserForm1.Show 

Part of user code:

 Private Sub OptionButton1_Click() Dim Loc As String Set XMLFile = CreateObject("Microsoft.XMLDOM") Set Loc = XMLFile.getElementsByTagName("loc") End Sub 

There is obviously some kind of error in the Userform code, for I get this: "Object Required" And it swears at this part of the code: XMLFile.getElementsByTagName("loc") Do not tell me how to fix this? And do I open the XML file correctly? Thank.

  • The assignment of the type Set var_name = object used for object variables, since you have a Loc string variable, then try to remove the Set keyword - Edward Izmalkov from the assignment line
  • This is how to open msdn.microsoft.com/ru-ru/library/ffice/ff838643.aspx - Alexander Puzanov

0