Announcement

Collapse
No announcement yet.

Call Glossary Sample from Access VBA?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Call Glossary Sample from Access VBA?

    Hi Folks,

    I have been looking through the PB/Win9 Glossary COM Server sample and would like to call it from Access 2003 if possible. I am having trouble creating the Glossary object in my VBA module. I believe this should be possible but there is a lot of information to take in and I wonder if I have missed something.

    I have set up the reference to the .tlb file.

    [Access 2003 Module1]... Tools Menu... References Menu...

    Available References... List of Glossary Terms and Definitions [Ticked for inclusion]
    Location: C:\PBWin90\Samples\Com\Glossary\GlossaryServer.tlb
    Language: Standard

    The VBA module contains the following sub...

    Code:
    Sub Test_Glossary()
         
         Dim oGlossary As Object
    
         Set oGlossary = CreateObject("Glossary.CGLOSSARY")
         
         Set oGlossary = Nothing
    
    End Sub
    VBA produces the following error when performing the CreateObject...

    Run-time error '429':
    ActiveX component cannot create object

    Has anyone else perhaps called a COM Server from VBA? If so could you offer me some guidance please?

    Thanks,

    David

    #2
    First I believe all strings need to be unicode.

    James

    Comment


      #3
      Hi James,

      > all strings need to be unicode

      I gave it a try from Access 97 (which is non-unicode) and I get the same error. Any ideas?

      I am floundering a little here (as you can probably tell).

      Cheers

      David

      Comment


        #4
        David,

        If you look at the class using OLEVW.EXE I believe that you will see that it is notcreatable. I have asked this question before and I was told that it was due to the fact that I didnt inherit from dual which is where I was inheriting from. I havnt been able to get this to work from vbscript or vb. I am not quite sure where the problem is coming from or what the problem is but I have tried creating three seperate different classes and interfaces to no avail.
        Sr. Software Development Engineer and Sr. Information Security Analyst,
        CEH, Digital Forensic Examiner

        Comment


          #5
          I thought I had posted this?? Maybe elsewhere?


          James

          Code:
          '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
          'SED_PBWIN
          '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
          
          
          '******************************************************************************
          '                            James C. Fuller
          '                            August 8, 2008
          '                         [email protected]
          '******************************************************************************
          #COMPILE DLL "JCFSERV.DLL
          #DIM ALL
          #COM NAME "JCFServer"
          #COM GUID GUID$("{C7214A4E-D4F7-456C-9F4A-994B56091E95}")
          #COM TLIB ON
          'This embeds the Typelib in the dll using José's SED
          '% RC TEXT 1 TYPELIB "JCFSERV.tlb"
          
          $cJcfServGuid = GUID$("{34D68488-BD5E-4F80-B060-84E373F4D112}")
          $iJcfServGuid = GUID$("{E211F708-8350-4CBE-B3B3-C6BD70E25108}")
          GLOBAL UserName AS STRING
          
          CLASS cJcfServ $cJcfServGuid AS COM
              INSTANCE L1 AS LONG
              INTERFACE iJcfServ $iJcfServGuid : INHERIT IDISPATCH
                  METHOD DoIt<101>() AS LONG
                      ?"I Am Here"+$CR + FORMAT$(L1)
                  END METHOD
                  PROPERTY GET L1<102>() AS LONG
                      PROPERTY = L1
                  END PROPERTY
                  PROPERTY SET L1<102>(BYVAL Param AS LONG)
                      L1 = Param
                  END PROPERTY
              END INTERFACE
          
          END CLASS
          '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
          You will need to register the server: regsvr32 JCFSERV.DLL
          '------------------------------------------------------------------------------
          Also I used Add Reference from the Project Menu of VB


          THis is the Vb 2008 Express Edition code.
          Just a Form with a button.

          Code:
          Public Class Form1
          
              Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                  Dim oJcf As JCFServer.IJCFSERV
                  Dim L2 As Integer
          
                  oJcf = CreateObject("CJCFSERV")
                  oJcf.L1 = 7
                  L2 = oJcf.DoIt()
          
              End Sub
          End Class

          Comment


            #6
            This doesnt work in VBA, VB or VBSCRIPT either. It might work in vb.net but not in the other vb's
            Sr. Software Development Engineer and Sr. Information Security Analyst,
            CEH, Digital Forensic Examiner

            Comment


              #7
              Thanks for the example code James, I just tried it from an Access 2003 module using a slightly modified version of your Button1_Click code...

              Code:
              Private Sub JCFServer_Test()
              
                      Dim oJcf As JCFServer.IJCFSERV
                      Dim L2 As Integer
              
                      Set oJcf = CreateObject("CJCFSERV")
                      oJcf.L1 = 7
                      L2 = oJcf.DoIt()
              
              End Sub
              Unfortunately Access failed in a fairly spectacular fashion generating an exception error as follows...

              Microsoft Office Access has encountered a problem and needs to close.
              We are sorry for the inconvenience.

              Code:
              Error signature
                AppName: msaccess.exe 
                AppVer: 11.0.8166.0
                AppStamp: 46437912
                ModName: jcfserv.dll
                ModVer: 0.0.0.0
                ModStamp: 00003039
                fDebug:0
                Offset: 00002def
              I had actually managed to make something similar to this happen with the Glossary example but thought I was doing something wrong. I'll continue digging.

              David

              Comment

              Working...
              X
              😀
              🥰
              🤢
              😎
              😡
              👍
              👎