Skip to content

The simple module for making requests to websites on VBA Excel

License

Notifications You must be signed in to change notification settings

tankalxat34/vbaRequests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

vbaRequests

GitHub top language GitHub

The simple module for making requests to websites

Author: tankalxat34

Installation

test

  1. Download this file or click to "DOWNLOAD" button.
  2. Open your Microsoft Excel Book and in window "Project - VBAProject" click on free place and than "Import file".
  3. Choice the downloaded file.
  4. Enjoy.

Information about "request" public function

Parameter Type Description
sURL String The string URL of web-site
headersDictionary Object Scripting.Dictionary A dictionary containing headers for making a successful request to a website. You can set the headers yourself, or use the "createHeaders" function to automatically apply default headers to your request
username String String containing your username for login in website
password String String containing your password or token for login in website
typeRequest String String of type for request: "GET", "POST", "PUT" and other types

Example

Get your own IP

This code will show you your IP address

Sub helloworld()
    Dim userIP As String
    userIP = vbaRequests.request("https://ifconfig.me/ip")
    MsgBox userIP
End Sub

Response from GitHub

Sub githubResponse()
    Debug.Print vbaRequests.request("https://api.github.com/users/tankalxat34", _
            vbaRequests.createHeaders(), _
            "tankalxat34", "YOUR_TOKEN", _
            "GET")
End Sub

Response from WGMods.net

Code:

Sub get_response()
    Dim headers As Object
    Set headers = CreateObject("Scripting.Dictionary")
    headers.Add "x-csrftoken", "NG97PVrI2orqk2UvBXyFB9GpHCNGHHFbbrRJogqbwFCEgTNoLsD383orPnQrq4wb"
    headers.Add "x-requested-with", "XMLHttpRequest"

    Debug.Print vbaRequests.request("https://wgmods.net/api/mods/2548/", vbaRequests.createHeaders(headers))
End Sub

Response from server here