Using Excel VBA to send Skype messages to Group Chat
Asked Answered
C

1

2

I'm trying to use Excel VBA to send Skype messages and I found this code

Sub Test()

Dim aSkype As SKYPE4COMLib.Skype
Set aSkype = New SKYPE4COMLib.Skype
Dim oChat As Chat
Dim skUser As SKYPE4COMLib.User
    Set skUser = aSkype.User("user_name")
    Set oChat = aSkype.CreateChatWith(skUser.Handle)
    oChat.OpenWindow
   oChat.SendMessage "automated message"

End Sub

and it works perfectly fine but only for single contacts.. I also found this code

msg.Chat.SendMessage("your message")

that's supposed to send messages to group contacts but I can't seem to integrate it to the above code.. I found a few links online which hints at it being possible but they're all in C# and not VBA.. Any help on this is very much appreciated..

Chilt answered 23/10, 2014 at 9:40 Comment(1)
jsut a wild guess but maybe it's supposed to be msg.oChat.SendMessage("your message")Surname
A
3

You need to define more than one user. One way is by using a collection.

Sub Test()    
  Dim aSkype As SKYPE4COMLib.Skype
  Set aSkype = New SKYPE4COMLib.Skype
  Dim oChat As Chat
  Dim skUser As SKYPE4COMLib.User

  Set oMembers = CreateObject("Skype4COM.UserCollection")
  oMembers.Add(oSkype.User("user_name1"))
  oMembers.Add(oSkype.User("user_name2"))

  Set oChat = oSkype.CreateChatMultiple(oMembers)       
  oChat.OpenWindow
  oChat.Topic = "Group Chat Topic"
  oChat.SendMessage "automated message"     
End Sub

Here is a great resource from Skype with lots of VBA examples. See page 21 for multi-chat.

Annulation answered 23/10, 2014 at 17:20 Comment(1)
Follow up question though, what if it's an existing chat group?Chilt

© 2022 - 2024 — McMap. All rights reserved.