Hello,

My Dev team set up a URL which I want to use to pull XML data into excel using VB.

My problem is that the URL requires a username and password.

I've referenced the threads that explain how to create a web query using the internet explorer object with a login and PW but I was not able to find anything about referencing an XML URL that requires a UN and PW.

I can get this to work through the data sources function in excel, which will produce an error and prompt me for a UN/PW in the web query window. Once I enter the login information once I can run the XML link repeatedly and it will work. I'm Looking to find a workaround in VB that would ideally prompt the user for their login information (but a generic login is also possible).

Thanks!

My code is below:


Sub GetMapping()

Dim UIxml As String
Dim CampaignID As String

CampaignID = Range("D2")

Sheets("XML Mapping").Select

UIxml = "https://URLThatRequiresLogin/" & CampaignID & "/EndOfURL"

    ActiveWorkbook.XmlImport URL:= _
        UIxml, ImportMap:= _
        Nothing, Overwrite:=True, Destination:=Range("$A$1")
        

End Sub