VBA访问网络
作者:互联网
Private Sub CommandButton1_Click() uploadData1 ("http://192.168.1.77:66/api/mes/TVbox?a=" + TextBox1.Text + "&b=" + TextBox2.Text + "&c=" + TextBox3.Text + "&d=" + TextBox4.Text + "&el=ExcelJson") End Sub Private Sub UserForm_Initialize() Dim wrokbook wrokbook = ActiveWindow.ActiveSheet.Name ThisWorkbook.Sheets(wrokbook).Cells(1, 1).Value = wrokbook + "年度计划达成率......." TextBox1.Text = Format(ThisWorkbook.Sheets(wrokbook).Cells(12, 3).Value, "0.00%") '光伏一达成率 TextBox2.Text = Format(ThisWorkbook.Sheets(wrokbook).Cells(13, 3).Value, "0.00%") '光伏一稼动率 TextBox3.Text = Format(ThisWorkbook.Sheets(wrokbook).Cells(19, 3).Value, "0.00%") '光伏一达成率 TextBox4.Text = Format(ThisWorkbook.Sheets(wrokbook).Cells(20, 3).Value, "0.00%") '光伏一稼动率 End Sub Function uploadData1(ByVal url As String) Dim http Set http = CreateObject("Microsoft.XMLHTTP") http.Open "GET", url, False http.send uploadData1 = http.Status Dim json$ json = http.responseText '获取返回数据 If http.Status = 200 Then MsgBox ("上传成功!!") Else MsgBox ("上传失败!!!!。" & Chr(13) & "错误原因:" + json) End If End Function
标签:ThisWorkbook,VBA,http,Text,Cells,网络,Value,访问,wrokbook 来源: https://www.cnblogs.com/jjyy2008cn/p/16698600.html