VBA/handler.bas

105 lines
2.2 KiB
QBasic

Option Explicit
Public sql As String
Public jsql As String
Public scenario As String
Public sc() As Variant
Public x As New TheBigOne
Public wapi As New Windows_API
Sub load_fpvt()
Call wapi.ClipBoard_SetData(sql)
fpvt.Show
End Sub
Sub pull_months(doc As String)
Dim req As New WinHttp.WinHttpRequest
Dim wapi As New Windows_API
Dim wr As String
Dim json As Object
Dim i As Long
With req
'.Open "GET", "http://10.56.1.108:3000/monthly_orders", True
.Open "GET", "http://192.168.1.69:3000/monthly_orders", True
.SetRequestHeader "Content-Type", "application/json"
.Send doc
.WaitForResponse
wr = .ResponseText
End With
Call wapi.ClipBoard_SetData(wr)
'MsgBox (wr)
On Error GoTo jerr
Set json = JsonConverter.ParseJson(wr)
jerr:
If Err.Number <> 0 Then
MsgBox ("function call error:" & vbCrLf & wr)
Exit Sub
End If
On Error GoTo errh
Sheets("test").range("A2:D1000").ClearContents
Sheets("test").range("N3:Q14").ClearContents
For i = 1 To json("jsonb_agg").Count
Sheets("test").Cells(i + 1, 1) = json("jsonb_agg")(i)("oseas")
Sheets("test").Cells(i + 1, 2) = json("jsonb_agg")(i)("monthn")
Sheets("test").Cells(i + 1, 3) = json("jsonb_agg")(i)("qty")
Sheets("test").Cells(i + 1, 4) = json("jsonb_agg")(i)("sales")
Next i
Sheets("test").Select
errh:
If Err.Number <> 0 Then
MsgBox (Err.Description)
End If
End Sub
Sub pg_main_workset()
Dim req As New WinHttp.WinHttpRequest
Dim wapi As New Windows_API
Dim wr As String
Dim json As Object
Dim i As Long
Dim doc As String
doc = "{""quota_rep"":""50200 - DORAN MARABLE""}"
With req
'.Open "GET", "http://10.56.1.15:3000/get_pool", True
.Open "GET", "http://192.168.1.69:3000/get_pool", True
.SetRequestHeader "Content-Type", "application/json"
.Send doc
.WaitForResponse
wr = .ResponseText
End With
Set json = JsonConverter.ParseJson(wr)
End Sub