VBA – Make Skype Call

Have you ever wanted to be able to initiate a Skype phone call at the click of a button? Well, the reality is that it is actually very simple to achieve.

The Basic Concept

The basic idea is that Skype follows a URI format which is used in HTML links and allows for interactivity between webpages and itself. The basic format being

[protocol]:[username]?[action]

So in the case of a phone call, it becomes

skype:[username]?call

Knowing the above, for making a call, we need to use a URI similar to:

skype:5555555555?call

Now that we understand what we want to do, there are a couple of ways we can go about using this URI functionality within our application. Mainly:

  • FollowHyperlink Method (Access specific)
  • Shell Function

Let’s briefly explore each of these approaches.

Application.FollowHyperlink Method

Now the simplest solution would be to simply use FollowHyperlink Method to invoke it. So one could do:

Application.FollowHyperlink "skype:5555555555?call"

The problem with the above is that you have to deal with security prompts which is never a good thing!
Access Skype Security Prompt

Shell

Now, as much as possible, we don’t want users receiving all sorts of pop-up dialogs, having to make extra clicks and even potentially stop our code from running, as is the case with the FollowHyperlink Method approach shown above.

So what is one to do?

In this instance, we can turn to using the Shell function.

This is done in 2 steps:

As such, the code, which bypasses security prompts is

'---------------------------------------------------------------------------------------
' Procedure : Skype_MakeCall
' Author    : Daniel Pineault, CARDA Consultants Inc.
' Website   : http://www.cardaconsultants.com
' Purpose   : Initiate Skype to make a phone call
' Copyright : The following is release as Attribution-ShareAlike 4.0 International
'             (CC BY-SA 4.0) - https://creativecommons.org/licenses/by-sa/4.0/
' Req'd Refs: Late Binding  -> none required
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' sNo             : Phone number to call / Can also be the name of a Skype contact
' bVideoCall      : True/False whether to make a video call
'
' Usage:
' ~~~~~~
' Call Skype_MakeCall("5555555555") 'Standard phone call
' Call Skype_MakeCall("LittleBubba") 'Standard phone call
' Call Skype_MakeCall("5555555555", False) 'Standard phone call
' Call Skype_MakeCall("5555555555", True) 'Video phone call
'
' Revision History:
' Rev       Date(yyyy-mm-dd)        Description
' **************************************************************************************
' 1         2021-09-15              Initial Public Release
' 2         2024-03-02              Corrected typo in function
'---------------------------------------------------------------------------------------
Public Function Skype_MakeCall(sNo As String, Optional bVideoCall As Boolean = False) As Boolean
    On Error GoTo Error_Handler
    Dim sSkypeExe             As String
    Dim sCmd                  As String
    Const sRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\skype.EXE\"

    sSkypeExe = CreateObject("WScript.Shell").RegRead(sRegKey)
    sCmd = """" & sSkypeExe & """  --_=""skype:" & sNo & "?call"""
    If bVideoCall = True Then sCmd = Replace(sCmd, "?call", "?call&video=true")
    shell sCmd, vbNormalFocus
    Skype_MakeCall= True

Error_Handler_Exit:
    On Error Resume Next
    Exit Function

Error_Handler:
    If Err.Number = -2147024894 Then
        'Skype not found
        MsgBox "Skype was not found.", vbCritical Or vbOKOnly, "Unable to Make Skype Call"
    Else
        'Other errors
        MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
               "Error Number: " & Err.Number & vbCrLf & _
               "Error Source: Skype_MakeCall" & vbCrLf & _
               "Error Description: " & Err.Description & _
               Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
               , vbOKOnly + vbCritical, "An Error has Occured!"
    End If
    Resume Error_Handler_Exit
End Function

And now you have a reusable function you can call as needed! (no pun intended 🙂 )

Exploring Skype’s Other Actions

Just as we can tap into the Call action, Skype exposes many other action. Feel free to explore them, below are a few that could be of interest:

  • add
  • chat
  • sendfile
  • voicemail
  • userinfo

A Few Resources on the Subject

2 responses on “VBA – Make Skype Call

  1. Greg Staffel

    Daniel, Thanks so much for this. This code worked until a skype update on 10/26 at which point I get an “invalid procedure call or parameter” message and Skype won’t launch or call the number. My workaround was to hardcode the old registry key
    Microsoft.SkypeApp_15.75.140.0_x86kf8qxf38zg5c Works (modified 10/4/2021)
    Microsoft.SkypeApp_15.77.97.0_x86kf8qxf38zg5c Does Not Work (modified 10/24/2021)
    Any thoughts?