Sending a message in Skype with VBA
Asked Answered
C

1

12

Objective: Send a message to a Skype contact when a certain macro is done.

Sources: I searched around and found a couple of question in SO trying to do the same thing. This is the base for the code I am using Using Excel VBA to send Skype messages to Group Chat and also this https://www.mrexcel.com/forum/excel-questions/424432-sending-skype-message-through-excel-vba.html Both these questions use a similar code.

Issue: When I run the code I get the following error:

Run-time error '429': ActiveX component can't create object

on the line:

Set aSkype = New SKYPE4COMLib.Skype

Question: Is this API still functional for this kind of procedure? How can I solve the ongoing error?

Code:

Sub testingskype()

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 "message"

End Sub

Obs: I am using option explicit in every module I create.

Cynthiacynthie answered 21/11, 2017 at 8:38 Comment(31)
May be you are using Skype for Business ,and SKYPE4COMLIB.skype does not support Skype / Lync for business #43140103Irresoluble
@Irresoluble Already checked that, I am using the normal skype version.Cynthiacynthie
Is Skype4COM 1.0 Type Library shown in tools >> references? Is it selected?Tropology
@destination-data Yes and Yes.Cynthiacynthie
Try with Set aSkype = CreateObject("SKYPE4COMLib.Skype"). Does that make a difference?Balboa
@Balboa Still get the same error, unfortunately.Cynthiacynthie
Found a thread with a similar problem. Solution there was to use Set aSkype = CreateObject("Skype4COM.Skype") (Notice the missing 'Lib') for late binding.Balboa
@Balboa Just tried that, still the same result. Would you mind sharing that thread?Cynthiacynthie
Sure. mrexcel.com/forum/excel-questions/…Balboa
You don't happen to be using 64-Bit Excel, do you?Balboa
@Balboa Yes I am, is there any incompatibility issue that I am not aware of?Cynthiacynthie
Well, I guess that's the issue then: #8577319 Try re-registering regsvr32 skype4com.dll .Balboa
@Balboa I tried running that line in CMD but got: "The module "skype4com.dll" failed to load.Cynthiacynthie
Need to run now, but there’s your problemBalboa
@Balboa I followed the instructions I got and got it to regestir by placing the dll file in other locations, but the original error still persists.Cynthiacynthie
Are you using 32 or 64 bit versions of Office & Skype ?Scarfskin
@PatrickHonorez 64, but I already tried in the 32 bit in another computer. Same error.Cynthiacynthie
Is Skype running when you start the code ?Scarfskin
Have you seen this ? https://mcmap.net/q/1012923/-excel-vba-skype4comlib-is-not-working-with-skype-for-business-sfb/78522Scarfskin
@PatrickHonorez I tried with both skype open and with it closed. Same Result. And yes, I did, as it was pointed out in a previous comment. I am not using Skype for Business.Cynthiacynthie
"The module "skype4com.dll" failed to load" can be a file not found error. Try moving the dll to the root c:\skype4com.dll and register with regsvr32 c:\skype4com.dllOrganotherapy
@Organotherapy as stated by some previous comments, there is a thread that explains how to do it, and nonetheless it has yielded the same result.Cynthiacynthie
@Cynthiacynthie I saw that comment but you have said that you got "Failed to load" message which may be a path issue. Like this: social.technet.microsoft.com/Forums/getfile/262956Organotherapy
Check that the registry key HKCR\WOW6432Node\CLSID\{830690FC-BF2F-47A6-AC2D-330BCB402664}\InprocServer32 has the default path C:\PROGRA~2\COMMON~1\Skype\SKYPE4~1.DLL and that it exists.Vicissitude
You could also try CreateObject("new:{830690FC-BF2F-47A6-AC2D-330BCB402664‌​}")Vicissitude
@Organotherapy Yes, I had done that before, the dll was registered sucessfully with precisely that command. Still the error from OP still persists.Cynthiacynthie
@FlorentB. I tried the option you suggested, still the same error. But I don't know how to check the registry key as you commented.Cynthiacynthie
either call reg QUERY HKCR\WOW6432Node\CLSID\{830690FC-BF2F-47A6-AC2D-330BCB402664}\InprocServer32 from cmd or execute regedit to view the registry.Vicissitude
@FlorentB. I get: "The system was unable to find the specified registry key or value"Cynthiacynthie
@DGMS89, It not possible to load a 32bits COM dll from a 64bits application (Excel here). Since Skype only comes as 32bits, I guess your only option is to switch to Excel 32bits.Vicissitude
Related question: https://mcmap.net/q/1012925/-access-lync-skype-for-business-conversation-in-cSlumber
H
0

This might not be of much help but I do not think the code that you have listed here works or the library is not added into your excel.

The same code turns up here: https://mcmap.net/q/1012923/-excel-vba-skype4comlib-is-not-working-with-skype-for-business-sfb

Did you download and register the skype dll (error has to do with not adding the activeX control it appears). It might only be x32 if you are using x64 ..

When you install software that uses the Skype4COM.dll dependency, the software should automatically register the file for you. In some cases your DLL file may not register properly, and as a result, will provide a "Skype4COM.dll not registered" error. Fortunately, you can use a built-in utility called "Microsoft Register Server" (regsvr32.exe) to re-register your Skype4COM.dll file. How to re-register Skype4COM.dll from an elevated command prompt (Windows XP, Vista, 7, 8, and 10):

Click the Start button.

Type "command" in the search box... DO NOT hit ENTER yet!

While holding CTRL-Shift on your keyboard, hit ENTER.

You will be prompted with a permission dialog box.

Click Yes.

Type the following command: regsvr32 /u Skype4COM.dll.

Hit ENTER. This will UN-REGISTER your file.

Type the following command: regsvr32 /i Skype4COM.dll.

Hit ENTER. This will RE-REGISTER your file.

Close the command prompt window.

Re-start the program associated with Skype4COM.dll error.

https://www.solvusoft.com/en/files/missing-not-found-error/dll/windows/skype-for-com-api/skype4com/skype4com-dll/

Cheers, WWC

Hutchings answered 1/12, 2017 at 21:0 Comment(1)
Thanks for the answer. I already tried that, also tried reinstalling skype and office. Same result.Cynthiacynthie

© 2022 - 2024 — McMap. All rights reserved.