Defining a reference to Microsoft Agent on a form

Posted on 2004-11-01
Last Modified: 2008-03-03
How do I define a reference to a Microsoft Agent on an Access form ? After putting the control on a form and trying this:
Dim myagent As Agent
 Set myagent = Forms!Form1!ActiveXctl0

I get "Type Mismatch".
Question by:leeskelton83
    LVL 16

    Expert Comment

    This syntax is wrong:

         Set myagent = Forms!Form1!ActiveXctl0

    If you are setting something, it must always be to an object.  In the VBA window, use the object browser (F2) to work out what these objects are.  

    I imagine the line should look something like this:

         Set myagent = myApp.Forms("Form1").ActiveXctl0


    LVL 3

    Author Comment

    No I can use Me.ActiveXCtl0 too and get the same thing.
    LVL 48

    Accepted Solution

    Try add the M$ Agent Control x.x Library from Reference, with an Agent placed on your form, then try:

    Dim Character As IAgentCtlCharacterEx

    charID = "MyCharacterName"
    charRunPath = "C:\windows\msagent\chars\myCharacter.acs"

    MyAgent.Characters.Load charID, charRunPath
        Set Character = MyAgent.Characters(charID)

    For more info, try see:

    Hope this helps
    LVL 3

    Author Comment

    What does is charID = "MyCharacterName"?
    LVL 48

    Expert Comment

    by:Ryan Chong
    sorry, as not response on this thread...

    >>What does is charID = "MyCharacterName"?
    Actually you can put whatever as you like.. in this line:

    MyAgent.Characters.Load charID, charRunPath

    what important will be the charRunPath, which indicates the location of the .acs (the character file) file to be loaded later.

    Will you still need help here, leeskelton83  ?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Anonabox PRO Tor & VPN Router

    PRO is the most advanced way to fortify your privacy and online anonymity by layering the Tor network with VPN services. Use both together or separately, and without needing to download software onto your devices.

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    846 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

    10 Experts available now in Live!

    Get 1:1 Help Now