This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Add the necessary references to your VBA project: | |
' - Microsoft XML, v6.0 | |
' - Microsoft Scripting Runtime | |
Public Function PostJsonWithBearerToken(apiUrl As String, jsonPayload As String, bearerToken As String) As String | |
Dim http As Object | |
Dim responseText As String | |
' Create the HTTP object | |
Set http = CreateObject("MSXML2.ServerXMLHTTP.6.0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Add the necessary references to your VBA project: | |
' - Microsoft XML, v6.0 | |
' - Microsoft Scripting Runtime | |
Public Function Base64Encode(text As String) As String | |
Dim arrData() As Byte | |
arrData = StrConv(text, vbFromUnicode) | |
Dim objXML As Object | |
Set objXML = CreateObject("MSXML2.DOMDocument.6.0") | |
Dim objNode As Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.http.HttpEntity; | |
import org.springframework.http.HttpHeaders; | |
import org.springframework.http.HttpMethod; | |
import org.springframework.http.MediaType; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.web.client.RestTemplate; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import java.util.HashMap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import okhttp3.*; | |
import com.google.gson.JsonObject; | |
import com.google.gson.JsonParser; | |
import java.io.IOException; | |
public class OAuth2TokenGenerator { | |
private static final String TOKEN_URL = "https://your-auth-server.com/oauth/token"; | |
private static final String CLIENT_ID = "your-client-id"; | |
private static final String CLIENT_SECRET = "your-client-secret"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Add the necessary references to your VBA project: | |
' - Microsoft XML, v6.0 | |
' - Microsoft Scripting Runtime | |
Public Function GetOAuth2TokenWithPassword(clientId As String, clientSecret As String, tokenUrl As String, username As String, password As String) As String | |
Dim http As Object | |
Dim json As Object | |
Dim jsonConverter As New JsonConverter | |
Dim payload As String | |
Dim responseText As String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub RunJavaScriptUsingIE() | |
On Error GoTo ErrorHandler | |
' Create Internet Explorer object | |
Dim ie As Object | |
Set ie = CreateObject("InternetExplorer.Application") | |
' Create an HTML page with JavaScript | |
Dim html As String | |
html = "<html><head><script type='text/javascript'>" & _ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub RunJavaScript() | |
' Declare the ScriptControl object | |
Dim sc As Object | |
Set sc = CreateObject("MSScriptControl.ScriptControl") | |
' Set the language to JavaScript | |
sc.Language = "JScript" | |
' Write the JavaScript code you want to execute | |
Dim jsCode As String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.jacob.activeX.ActiveXComponent; | |
import com.jacob.com.Dispatch; | |
import com.jacob.com.Variant; | |
public class UpdateExcel { | |
public static void main(String[] args) { | |
// Create an instance of the Excel application | |
ActiveXComponent excelApp = new ActiveXComponent("Excel.Application"); | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashSet; | |
import java.util.Set; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class PlaceholderExtractor { | |
public static void main(String[] args) { | |
String input = "abc %current_uk_time% test %another_one%"; | |
// Extract placeholders from the input string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class PlaceholderReplacer { | |
public static void main(String[] args) { | |
String input = "abc %current_uk_time% test %another_one%"; | |
// Create a map with placeholder values |
NewerOlder