The article shows how to send a message form Excel to a Telegram group using VBA script.

To send messages to a Telegram group you need:

  1. Create a Telegram bot using @BotFather and save its Token (provided by @BotFather)
  2. Create a Telegram group ("New group" in the menu) and add the bot to this group
  3. Obtain chat_id for the group (for example, you can use @RawDataBot or @UserInfoBot)
  4. Use the script below to send text via Telegram bot from Excel
'-------------------------------------------------------------------------
' Source: risksir.com
' Description: Sending text to Telegram group with a bot from Excel
'-------------------------------------------------------------------------

Sub SendToTelegram()

    Dim ChatId As String
    Dim BotToken As String
    Dim MessageText As String
    Dim SendPostData As String
    Dim TGPostObject As Object
     
    ChatId = "-6942069420"  'Replace -6942069420 with your Telegram group chat_id
    BotToken = "6969696969:AAGY7i69JzMMz_o5Yr7sFAXlCRKWXI5T-vY" 'Replace 6969696969:AAGY7i69JzMMz_o5Yr7sFAXlCRKWXI5T-vY with your bot token
     
    MessageText = "Hello world!"
    SendPostData = "chat_id=" & ChatId & "&text=" & MessageText
     
    Set TGPostObject = CreateObject("MSXML2.XMLHTTP")
    
    With TGPostObject
      .Open "POST", "https://api.telegram.org/bot" & BotToken & "/sendMessage?", False
      .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
      .send (SendPostData)
       GetSessionId = .responseText
       MsgBox GetSessionId
    End With
 
End Sub


 

Download an example xlsm