Click here to Skip to main content
13,293,178 members (84,205 online)
Click here to Skip to main content
Add your own
alternative version


5 bookmarked
Posted 14 Apr 2010

Visual Studio Class Library for Microsoft Access

, 14 Apr 2010
Rate this:
Please Sign up or sign in to vote.

In this article of let's understand how to create, manage, and deploy a library (class library) for Microsoft Access. Let's use the Visual Studio 2008, C#, Visual Basic and Microsoft Access 2007.


Let's understand how access communicates with the Microsoft Framework using COM Interop

Using the Code

You have to Add the Framework Assembly to your VBA Project and invoke it like

"Dim obj As New Ukase.M3CommonFunctions"


  1. Create the library
  2. Initials configurations
  3. COM Visibility settings
  4. First property
  5. COM Implementation

Why implement a class library in Microsoft Access?

If you implement a class and spelling out the same, we are allowing Microsoft Access you can use its resources, i.e. we can use the facilities of Microsoft framework in VBA code by adding a reference to the DLL. We may also use it in another project, Visual Studio as an add-in.


public class M3CommonFunctions : IM3CommonFunctions


   public interface IM3CommonFunctions
       Version GetMACLVersion  { get; }


Assembly asm = Assembly.GetExecutingAssembly();
     public Version GetMACLVersion
         get {  return asm.GetName().Version; }


<ComClass(Namespace_Comuns.ClassId, Namespace_Comuns.InterfaceId, Namespace_Comuns.EventsId)> _
Public Class Namespace_Comuns
    Private m_VersaoBiblioteca As String
#Region "COM GUIDs"
    ' These  GUIDs provide the COM identity for this class 
    ' and its COM interfaces. If you change them, existing 
    ' clients will no longer be able to access the class.
    Public Const ClassId As String = "6b6c0965-e6a5-4089-afbb-0ec787efe024"
    Public Const InterfaceId As String = "d8c53404-58b4-4f28-9d2f-4912f8cb6723"
    Public Const EventsId As String = "165be10c-a5a6-4d57-ac49-0ad7a8bd1cd5"
#End Region
    ' A creatable COM class must have a Public Sub New() 
    ' with no parameters, otherwise, the class will not be 
    ' registered in the COM registry and cannot be created 
    ' via CreateObject.
    Public Sub New()
    End Sub
    Public ReadOnly Property VersaoBiblioteca() As String
            m_VersaoBiblioteca = My.Application.Info.Version.ToString
            Return m_VersaoBiblioteca
        End Get
    End Property
End Class

Using in Access VBA Code

Private Sub Command0_Click()
    Dim obj As New Ukase.M3CommonFunctions
    MsgBox obj.GetMACLVersion
End Sub

Points of Interest

NET COM Library Samples for Microsoft Access


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Joao Tito Livio
Software Developer (Senior)
Portugal Portugal
I'am Developing my career in the IT industry and development, having worked specifically in areas related to system administration, database Administration and development. Developed specific skills in developmental screening/support for technical incidents, network management, Server Administration, software development, training, project management and technical advice.

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 14 Apr 2010
Article Copyright 2010 by Joao Tito Livio
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid