使用vba从受密码保护的站点获取数据时出现运行时错误91

时间:2017-05-10 10:11:56

标签: vba

以下是我正在使用的代码:

Set IE = CreateObject("InternetExplorer.Application")

    With IE
        .Visible = True
        .Navigate "https:......" 
        Do Until .ReadyState = 4
            DoEvents
        Loop
    .document.all.Item("sso_username").Value = "username"
    .document.all.Item("ssopassword").Value = "password"
    .document.forms(1).submit
    End With



   With ActiveSheet.QueryTables.Add(Connection:= _
   "URL;https:...." , Destination:=Range("A2"))
      .Name = "q?s=goog_2"
      .FieldNames = True
      .RowNumbers = False
      .FillAdjacentFormulas = False
      .PreserveFormatting = True
      .RefreshOnFileOpen = False
      .BackgroundQuery = True
      .RefreshStyle = xlInsertDeleteCells
      .SavePassword = False
      .SaveData = True
      .AdjustColumnWidth = True
      .RefreshPeriod = 0
      .WebSelectionType = xlSpecifiedTables
      .WebFormatting = xlWebFormattingNone
      .WebTables = "1,2"
      .WebPreFormattedTextToColumns = True
      .WebConsecutiveDelimitersAsOne = True
      .WebSingleBlockTextImport = False
      .WebDisableDateRecognition = False
      .WebDisableRedirections = False
      .Refresh BackgroundQuery:=False
  End With

显示错误   .document.all.Item(“sso_username”)。Value =“username” 有谁能让我知道我错过了什么?

0 个答案:

没有答案