[AccessD] Class builder

Shamil Salakhetdinov shamil at users.mns.ru
Fri Jan 13 02:53:13 CST 2006


John,

Here is one of the methods how a new class module can be created and saved
using VBA:

Dim mdl As Access.Module
Dim objApp As Access.Application
Dim strTempMdlName As String
Dim strMdlName As String
    Set objApp = Access.Application
    strMdlName = "CTestClassModule"

    With objApp.DoCmd
        .RunCommand acCmdNewObjectClassModule
        Set mdl = objApp.Modules.Item(objApp.Modules.Count - 1)
        strTempMdlName = mdl.Name

        mdl.InsertText "public TestProperty as integer"

        .Close acModule, strTempMdlName, acSaveYes
        .Rename strMdlName, acModule, strTempMdlName
    End With

Make sure there is no class module with the name CTestClassModule in your
database...

Shamil

----- Original Message ----- 
From: "John Colby" <jwcolby at ColbyConsulting.com>
To: "'Access Developers discussion and problem solving'"
<accessd at databaseadvisors.com>
Sent: Friday, January 13, 2006 4:08 AM
Subject: [AccessD] Class builder


> I have just finished a little class builder.  If anyone wants to play with
> it let me know.
>
> In the meantime, the one thing I can't figure out is how to save the newly
> created class.  I can click the save button and it saves the new module,
but
> I can't make it happen from VBA.  Anyone know what object saves unsaved
> modules?
>
> John W. Colby
> www.ColbyConsulting.com
>
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com




More information about the AccessD mailing list