How do I reference an older version of SAPI

Posted on 2012-08-25
Last Modified: 2012-08-25
I have developed a Microsoft Access program that uses a reference to Microsoft Speech Object Library. It allows me to add a little "fun" into an otherwise boring application.

I have developed the app on a Windows 7 PC that has Windows SAPI version 5.4 but when I try to run it on XP machines which runs an earlier version of SAPI, I get a missing or broken reference.

I want to distribute this as an MDE that will run with MS Access 2007 runtime and have it work on either Windows 7 or XP machines.

Does anyone know how I can distribute it with an earlier version SAPI? I know where to find the DLL on an XP Machine. Is it simply a case of distributing the earlier SAPI and registering it on the target machine or is that likely to mess things up badly?
Question by:Rob4077
    LVL 61

    Expert Comment


    It's hard to say without seeing the actual code.  But in general to avoid reference problems, you  can use 'Late Binding', which declares things as Objects rather than types specific to the libraries you are using.

    For example. this is Early Binding, which will cause problems in a mixed version environment:

    Dim objExcel as Excel.Application

    To avoid reference problems between versions of Excel on different machines, you would replace that with Late Binding:

    Dim objExcel as Object

    That is the basic idea.  However some libraries have constants that would also have to be changed.  For example Excel has constants that can be used in code like xlBottom (or something like that) for the bottom border of a cell.  Using Late binding, constants like that need to be replaced with their actual value.  Chances are your code does not use any.  The quickest way to find out is to change the relevant declarations to Object and see if you code compiles.

    As an aside, you lose vba's intellisense when you use late binding.  To make development easier, include declarations for both early and late binding.  When developing code, use early binding (Dim xlApp as Excel.Application), so that you can use intellisense/autocomplete as you are writing your code.  When your project is ready to release, comment that out and switch to "Dim xlApp as Object" to avoid reference issues.

    That's generally how to do this - and might also help with the Speech Object Library (which I personally have never used).

    You could try it out on a small 'test' database before applying it to your own db to see how it works.

    Author Comment

    Hi mbuzup,

    Thanks for your explanation. The code it very straightforward but I can't seem to get it to work with late binding so I assume I am doing something wrong.
    Here's the early binding code:

        Dim s As SpeechLib.SpVoice
        Set s = New SpeechLib.SpVoice
        s.Volume = 100
        s.speak Message
        Set s = Nothing

    When I change to late binding (which I think should be as follows), I get the message "ActiveX component cant create object"

        Dim speaknow As Object
        Set speaknow = CreateObject("SpeechLib.SpVoice")
        speaknow.Volume = 100
        speaknow.speak Message
        Set speaknow = Nothing
    LVL 77

    Expert Comment

    Have you definitely removed the SAPI reference from the references  list?

    Author Comment

    I hadn't but I have now and it still does the same thing.

    I tried compiling on an XP machine then running on a Windows 7 machine and it works OK, but I don't want to do it that way unless I absolutely have to

    Author Comment

    Here's a sample dbf that works when I run it from Windows 7 but not from XP. How do I convert?
    LVL 77

    Expert Comment

    What I have seen before uses....

    Set speaknow = CreateObject("SAPI.SpVoice")

    but I don't have this library on my current machine so can't test anything.
    LVL 77

    Accepted Solution

    Just googled for an example... see here...

    Author Comment

    Hi Peter,

    that did the trick. Thanks for your help, yet again.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    Forms or tables Name 4 47
    Show Balance 3 15
    Day count current month 3 23
    Table Bound to a Form - MS Access 6 22
    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now