Send PDF file to a webhook with VBA

nd0911 86 Reputation points
2023-01-02T15:37:40.147+00:00

I have a Make (Integromat) webhook and I want to send a PDF file via Excel VBA.

The PDF file is on my desktop path.

This is the code I have:

Public Sub SendPDF()  
Dim URL As String  
Dim Req As Object  
Dim PdfFullPath As String  
  
  
Set Req = CreateObject("WinHttp.WinHttpRequest.5.1")  
  
On Error GoTo Er  
  
  
PdfFullPath = "C:\Users\MyUserName\Desktop\MyPDF.pdf"  
  
URL = "https://hook.make.com/xxxxxx?"  
  
  
  
Req.Open "POST", URL, False  
Req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"  
Req.Send  
  
  
MsgBox Req.ResponseText  
  
Exit Sub  
  
Er:  
End Sub  

Is it possible to do it ?

Thank you.

Developer technologies Visual Basic for Applications
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Oskar Shon 866 Reputation points
    2023-01-04T18:31:50.533+00:00

    You do not use PdfFullPath variable in your post commend.
    so try it like:

    Req.Send PdfFullPath   
    

    and I used another control for that job:

    CreateObject("Msxml2.ServerXMLHTTP")  
    

    You an find easily article about that.

    Regards

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.