Using Excel VBA to send Skype messages to Group Chat

↘锁芯ラ 提交于 2019-12-24 02:45:09

问题


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..


回答1:


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.



来源:https://stackoverflow.com/questions/26525303/using-excel-vba-to-send-skype-messages-to-group-chat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!