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.
Set var_name = objectused for object variables, since you have aLocstring variable, then try to remove theSetkeyword - Edward Izmalkov from the assignment line