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.

braX
  • 11,506
  • 5
  • 20
  • 33
DGMS89
  • 1,507
  • 6
  • 29
  • 60
  • May be you are using Skype for Business ,and SKYPE4COMLIB.skype does not support Skype / Lync for business https://stackoverflow.com/questions/43139603/excel-vba-skype4comlib-is-not-working-with-skype-for-business-sfb – PankajKushwaha Nov 21 '17 at 08:58
  • @PankajKushwaha Already checked that, I am using the normal skype version. – DGMS89 Nov 21 '17 at 09:10
  • Is `Skype4COM 1.0 Type Library` shown in *tools* >> *references*? Is it selected? – David Rushton Nov 21 '17 at 12:41
  • @destination-data Yes and Yes. – DGMS89 Nov 21 '17 at 12:54
  • 1
    Try with `Set aSkype = CreateObject("SKYPE4COMLib.Skype")`. Does that make a difference? – LocEngineer Nov 21 '17 at 15:46
  • @LocEngineer Still get the same error, unfortunately. – DGMS89 Nov 22 '17 at 11:19
  • Found a thread with a similar problem. Solution there was to use `Set aSkype = CreateObject("Skype4COM.Skype")` (Notice the missing 'Lib') for late binding. – LocEngineer Nov 22 '17 at 11:30
  • @LocEngineer Just tried that, still the same result. Would you mind sharing that thread? – DGMS89 Nov 22 '17 at 11:40
  • Sure. https://www.mrexcel.com/forum/excel-questions/774338-add-skype-reference-using-late-binding.html – LocEngineer Nov 22 '17 at 12:03
  • You don't happen to be using 64-Bit Excel, do you? – LocEngineer Nov 22 '17 at 16:23
  • @LocEngineer Yes I am, is there any incompatibility issue that I am not aware of? – DGMS89 Nov 22 '17 at 16:29
  • Well, I guess that's the issue then: https://stackoverflow.com/questions/8576819/cannot-add-reference-to-skype4com-dll-on-windows-7-x64 Try re-registering `regsvr32 skype4com.dll` . – LocEngineer Nov 22 '17 at 16:41
  • @LocEngineer I tried running that line in CMD but got: "The module "skype4com.dll" failed to load. – DGMS89 Nov 22 '17 at 16:51
  • Need to run now, but there’s your problem – LocEngineer Nov 22 '17 at 16:52
  • @LocEngineer 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. – DGMS89 Nov 22 '17 at 17:18
  • Are you using 32 or 64 bit versions of Office & Skype ? – iDevlop Nov 29 '17 at 14:12
  • @PatrickHonorez 64, but I already tried in the 32 bit in another computer. Same error. – DGMS89 Nov 29 '17 at 14:14
  • Is Skype running when you start the code ? – iDevlop Nov 29 '17 at 14:35
  • Have you seen this ? https://stackoverflow.com/q/43139603/78522 – iDevlop Nov 29 '17 at 14:36
  • @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. – DGMS89 Nov 29 '17 at 14:47
  • "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.dll – alpere Dec 01 '17 at 00:38
  • @alpere as stated by some previous comments, there is a thread that explains how to do it, and nonetheless it has yielded the same result. – DGMS89 Dec 01 '17 at 09:39
  • @DGMS89 I saw that comment but you have said that you got "Failed to load" message which may be a path issue. Like this: https://social.technet.microsoft.com/Forums/getfile/262956 – alpere Dec 01 '17 at 13:45
  • 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. – Florent B. Dec 01 '17 at 14:02
  • You could also try `CreateObject("new:{830690FC-BF2F-47A6-AC2D-330BCB402664‌​}")` – Florent B. Dec 01 '17 at 14:04
  • @alpere Yes, I had done that before, the dll was registered sucessfully with precisely that command. Still the error from OP still persists. – DGMS89 Dec 01 '17 at 14:20
  • @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. – DGMS89 Dec 01 '17 at 14:21
  • 1
    either call `reg QUERY HKCR\WOW6432Node\CLSID\{830690FC-BF2F-47A6-AC2D-330BCB402664}\InprocServer32` from cmd or execute `regedit` to view the registry. – Florent B. Dec 01 '17 at 14:26
  • @FlorentB. I get: "The system was unable to find the specified registry key or value" – DGMS89 Dec 01 '17 at 14:28
  • @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. – Florent B. Dec 03 '17 at 13:55

2 Answers2

2

It surprised me that developers gave up on this question when the chat automation is the topic of discussion everywhere.

"Skype for Business" is basically a rebranded Lync since 2013, so it's important to understand that

Skype <> "Skype for Business"

It's like java and javascript, totally different, just similar names for branding.


It is important to understand the Skype Developer Platform or simply Skype SDK which is umbrella for Office Skype, Skype Web, Skype for Business and Skype.

Skype Developer Platform

Among all APIs/SDKs, one needs to use:

Lync 2013 SDK documentation

As this is single available SDK for Skype Desktop, Lync and all following SFB versions.

Persistent chat samples is what one should use to develop upon their solution similar to this question.

jainashish
  • 4,702
  • 5
  • 37
  • 48
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://stackoverflow.com/a/43172531/8716187

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

  • Thanks for the answer. I already tried that, also tried reinstalling skype and office. Same result. – DGMS89 Dec 06 '17 at 13:33