背景/目标:Web Scrape:使用.send
的语法问题我正在尝试从两列单元格中的名称列表中发送姓氏和名字,我遇到语法错误,因为它无法识别单元格并假设范围是" name&# 34;
代码: 语法错误从" last"开始。和"第一" .send下的一行,因为我试图发送一个单元格值而不是键入名称。引用一系列单元格时的正确格式是什么?
Option Explicit
Sub Test()
Dim sContent As String
Dim i As Long
Dim j As Long
Dim aHeader() As String
Dim aRows() As String
' Retrieve HTML content via XHR
With CreateObject("MSXML2.XMLHTTP")
.Open "POST", "http://npinumberlookup.org/getResults.php", False
.setRequestHeader "content-type", "application/x-www-form-urlencoded"
.send _
"last=Range(G:1)" & _
"&first=Range(F:1)" & _
"&pracstate=TX" & _
"&npi=" & _
"&submit=Search"
答案 0 :(得分:0)
当你想引用一个Range的值时,就像@Qharr之前说的那样。我试过了:
' Retrieve HTML content via XHR
With CreateObject("MSXML2.XMLHTTP")
.Open "POST", "http://npinumberlookup.org/getResults.php", False
.setRequestHeader "content-type", "application/x-www-form-urlencoded"
.send _
"last=" & Range("G1").Value & _
"&first=" & Range("F1").Value & _
"&pracstate=TX" & _
"&npi=" & _
"&submit=Search"
End With
它有效。运行代码时没有错误。