使用 Excel VBA 向群聊发送 Skype 消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26525303/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using Excel VBA to send Skype messages to Group Chat
提问by TrevorDhien
I'm trying to use Excel VBA to send Skype messages and I found this code
我正在尝试使用 Excel VBA 发送 Skype 消息,但我找到了此代码
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..
那应该向群组联系人发送消息,但我似乎无法将其集成到上面的代码中。这是非常感谢..
回答by Portland Runner
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 Skypewith lots of VBA examples. See page 21 for multi-chat.
这是来自 Skype 的一个很好的资源,里面有很多 VBA 示例。请参阅第 21 页的多聊天。