VBA - add in username and password to open a web page then download

j4ymf

Well-known Member
Joined
Apr 28, 2003
Messages
741
Office Version
  1. 365
Platform
  1. Windows
Hello
this code works and downloads the data of the corona virus and pastes it in A10

I would like to change the site in the URL line that requires a username and password
where do I data in a username and password in the VBA


VBA Code:
Sub Get_webpage()

    'clear old data
   Rows("6:251").Select
    Selection.Delete Shift:=xlUp

    On Error GoTo error
    Application.ScreenUpdating = False
    
        With Sheets("Sheet1").QueryTables.Add(Connection:= _
            "URL;https://virusncov.com", _
             '"URL;http://88.215.27.26/Firetronic/Auth/App.aspx?list=BLCustom_4&mitId=1016&", _
            Destination:=Sheets("Sheet1").Range("A10"))
        
            .BackgroundQuery = True
            .TablesOnlyFromHTML = True
            .Refresh BackgroundQuery:=False
            .SaveData = True
        End With
        

error:
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hello
Ive pinched some code but it still does not login and bring down the data!!
Please could you help?

VBA Code:
Sub Get_webpage()

Rows("6:251").Select
    Selection.Delete Shift:=xlUp

    'Copy web page to sheet1
    On Error GoTo error
    Application.ScreenUpdating = False
    
    Set ie = CreateObject("InternetExplorer.Application")
    With ie
        .Visible = True
        .Navigate "http://88.215.27.26/Firetronic/Login.aspx?ReturnUrl=Auth/App.aspx"
        Do Until .ReadyState = 4
            DoEvents
        Loop
        .document.all.Item("loginUserName").Value = "xxxxx"
        .document.all.Item("loginUserPassword").Value = "xxxxx"
        .document.forms(0).submit
    End With
 
    
        With Sheets("Sheet1").QueryTables.Add(Connection:= _
            "URL;http://88.215.27.26/Firetronic/Auth/App.aspx?list=BLCustom_4&mitId=1016&#", _
            Destination:=Sheets("Sheet1").Range("A10"))
        
            .BackgroundQuery = True
            .TablesOnlyFromHTML = True
            .Refresh BackgroundQuery:=False
            .SaveData = True
        End With
        
error:
Application.ScreenUpdating = True

Range("B5").Select


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,075
Members
449,205
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top