How to Send Excel Automation Result to Telegram Using UiPath?

Hi, thank you for your reply!

Just to give a bit of context: my automation takes data from three different Excel files, combines them into a single workbook with multiple sheets, and then summarizes the key information into a final sheet called “SummaryReport”. After that, I use VBA through the “Invoke VBA” activity to send the summary table via Telegram.

I already used a separate .txt file for the VBA code in the Invoke VBA activity, but I’m still getting the same error regarding “Trust access to the VBA project object model” even though I’ve already enabled the option in Excel settings.

Do you think there’s something wrong with my code, or could there be another setting that I’m missing?

Here’s the VBA code I’m using:
Sub GenerateAllReports()
’ Step 1: Proses untuk membuat Top5Client dan Top5SID
Call CopyAndSortTop5Sheets

' Step 2: Buat summary report berdasarkan Top5Client dan Top5SID
Call CreateSummaryReport

' Step 3: Kirim laporan ke Telegram
Call SendTelegramReport

End Sub

Sub SendTelegramReport()
Dim http As Object
Dim URL As String
Const botToken As String = “YOUR_BOT_TOKEN” ’ Replace with your bot token
Const chatID As String = “YOUR_CHAT_ID” ’ Replace with your chat ID
Dim messageText As String
Dim wsSummary As Worksheet
Dim tableRange As Range
Dim tableData As Variant
Dim i As Long, j As Long
Dim response As String

' Check if "SummaryReport" sheet exists
On Error Resume Next
Set wsSummary = ThisWorkbook.Sheets("SummaryReport")
If wsSummary Is Nothing Then
    MsgBox "Sheet 'SummaryReport' not found!", vbExclamation
    Exit Sub
End If
On Error GoTo 0

' Set the data range to be sent
Set tableRange = wsSummary.Range("A1:D18")
tableData = tableRange.Value

' Create the message
messageText = "📊 *Telkomcel Daily Report*" & vbCrLf
messageText = messageText & "📅 " & Format(Date, "dddd, mmmm dd, yyyy") & vbCrLf & vbCrLf

For i = 1 To UBound(tableData, 1)
    For j = 1 To UBound(tableData, 2)
        messageText = messageText & tableData(i, j) & " | "
    Next j
    messageText = messageText & vbCrLf
Next i

' Truncate if message is too long
If Len(messageText) > 4000 Then
    messageText = Left(messageText, 4000) & "... (truncated)"
End If

' Encode URL
messageText = Application.EncodeURL(messageText)

' Telegram API URL
URL = "https://api.telegram.org/bot" & botToken & "/sendMessage?chat_id=" & chatID & "&text=" & messageText & "&parse_mode=Markdown"

' Send request
On Error Resume Next
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", URL, False
http.Send
response = http.responseText
On Error GoTo 0

If InStr(response, """ok"":true") > 0 Then
    MsgBox "Report successfully sent to Telegram!", vbInformation
Else
    MsgBox "Failed to send report! Please check your bot token and chat ID.", vbCritical
End If

Set http = Nothing

End Sub

Thanks again for taking the time to assist!