Add Skype reference using Late binding

MarkCBB

Active Member
Joined
Apr 12, 2010
Messages
497
Hi there,

I found the following code that sends a Skype message. It works perfectly when I add the Skype object reference manually. However I would like to distribute this code, is there a away to use late binding to automatically add the Skype reference on run time? Below is the code.
Code:
Sub Skype_ContactCount()

Dim aSkype As SKYPE4COMLib.Skype
Dim int_NumberOfSkypeUserContacts

Set aSkype = New SKYPE4COMLib.Skype

int_NumberOfSkypeUserContacts = aSkype.Friends.Count

Dim oChat As chat
Dim skUser As SKYPE4COMLib.user
    Set skUser = aSkype.user("UserName") ' Add Skype name here
    Set oChat = aSkype.CreateChatWith(skUser.Handle)
    oChat.OpenWindow
    oChat.SendMessage "Hello " & skUser.FullName & " " & Application.UserName & " has " & int_NumberOfSkypeUserContacts & " Skype contacts"
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Maybe try:

Code:
Dim aSkype As Object
Dim int_NumberOfSkypeUserContacts

Set aSkype = CreateObject("SKYPE4COMLib.skype")
 
Upvote 0
Hi Andrew,

I have tried that but I get the following Error. "ActiveX component can't create Object.
 
Upvote 0
Which line does it break on?

Perhaps:
Code:
Set aSkype = CreateObject("Skype4COM.Skype")

You need to dimension aSkype, oChat and skUser as Object...

Edit: Just because you use early binding doesn't mean each user will have to set reference. IF there are problems on other user machines it may be because that library doesn't exist on their machine (perhaps they haven't got skype), so late binding still won't work.
 
Upvote 0
Hi Jon,

Thankfully, the user group is small and they all have Skype.

Below is where the code is crashing, I have cleaned it up a bit, but Not sure what I am doing wrong, and I am not finding a lot via Google.
Code:
Sub Skype_MessageTest()
Dim aSkype As Object
Dim oChat As Object
Dim skUser As Object

Set aSkype = CreateObject("SKYPE4COMLib.Skype") ' error here
Set skUser = aSkype.user("markblackburn86")
Set oChat = aSkype.CreateChatWith(skUser.Handle)
    
oChat.SendMessage "Hello"
End Sub
 
Upvote 0
Wait....
Didn't see the change you added.
seems to b working well.
Thank you.
 
Upvote 0

Forum statistics

Threads
1,221,499
Messages
6,160,163
Members
451,628
Latest member
Bale626

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top