Hello, @paul1149
Your approach is on the right track! To perform an HTTP POST request from your macro, you’ll need to modify your Web_Lookup function to handle POST requests. Let’s break it down:
Construct the URL: You’ve already defined the URL for your POST request:
Code: Select all
https://www.blueletterbible.org/search/preSearch.cfm{POSTARGS}Criteria=%s&t=NASB95&csr=0&csrf=0&csrt=0&cscs={POSTENCODING}UTF-8
Replace {POSTARGS} with the actual arguments you want to send (e.g., search criteria), and {POSTENCODING} with the appropriate encoding (usually application/x-www-form-urlencoded).
Create the HTTP request: You can use WinHttp.WinHttpRequest.5.1 to send the POST request. Here’s how you can modify your Web_Lookup function:
Code: Select all
Function Web_Lookup(site As String, token As String)
Dim http As Object
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
' Construct the URL with your POST arguments
Dim url As String
url = "https://www.blueletterbible.org/search/preSearch.cfm" & _
"?Criteria=" & oSel & "&t=NASB95&csr=0&csrf=0&csrt=0&cscs=UTF-8"
' Open the request
http.Open "POST", url, False
' Set any additional headers if needed (e.g., User-Agent)
http.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
' Send the request
http.send ""
' Handle the response (you can access it via http.responseText)
' For example, display it in a message box:
MsgBox http.responseText
End Function
Invoke the function: Call your modified Web_Lookup function with the appropriate site and token values.
Remember to replace placeholders like {POSTARGS} and {POSTENCODING} with actual values relevant to your search. If you need to pass specific data (e.g., JSON payload), adjust the http.send line accordingly.
Feel free to adapt this example to your specific use case.
Hope this work for you.
Best Regards,
john125wheeler
User banned (post edited to add a spam link. Post however kept since the code may be of some help (Hagar, Moderator).
OpenOffice 3.1 on Windows Vista | NeoOffice 2.2.3 with MacOS 10.4 | OpenOffice 2.4 on Ubuntu 9.04