如何在.Open" Get"中引用一个值。声明在VBA中的声明

时间:2014-07-30 08:48:06

标签: vba

我在sub中有引用值,但我想在GET语句中使用引用的值。 我想使用我的num1值作为我的脱色=在我的.Open" Get"言。

 Dim num1 As String
 Set htm = CreateObject("htmlFile")
 num1 = Cells(2, 2).Value
 With CreateObject("msxml2.xmlhttp")
    .Open "GET", "https://maps.googleapis.com/maps/api/distancematrix/json?origins=sy10 5tp&destinations='num1'&mode=driving&language=en-GB&v=3&sensor=fals", False

非常感谢。

1 个答案:

答案 0 :(得分:1)

使用"关闭带引号的字符串文字并使用&连接运算符附加变量:

x = "abc" & stringVariable & "def"

所以

.Open "GET", "https://maps.googleapis.com/maps/api/distancematrix/json?origins=sy10 5tp&destinations=" & num1 & "&mode=driving&language=en-GB&v=3&sensor=fals", False

(您还有fals,大概应该是false