[AccessD] Saving Code Builder generated class

John Colby jwcolby at ColbyConsulting.com
Fri Jan 13 10:40:04 CST 2006


Well, I am trying to build a class in the project, not in the add-in.  In my
tiny mind, if I use CurrentProject I should get a handle to the stuff in the
application, thus if I build a module it should be built in the
CurrentProject. If I use CodeProject, then I would be telling it to build
the class in the container where the code is currently running which is the
add-in, not what I want.

John W. Colby
www.ColbyConsulting.com 


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust
Sent: Friday, January 13, 2006 11:14 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Saving Code Builder generated class

John,

Don't you want to use CodeProject instead of CurrentProject when referring
to the add-in?  

Charlotte


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Colby
Sent: Friday, January 13, 2006 7:12 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Saving Code Builder generated class


It appears that Access is getting confused as to where the class is being
built.  I have a framework linked in to my FE and apparently the add-in
can't figure out what container the class belongs in.  When I create the
class and go look at it (it opens so I can see it) but up at the top it says
the container is the Add-In.  The save button is not grayed out but if I try
and click it, nothing happens.  If I then cut the code out and insert
another class and paste the code back in, I still can't save it.  If I open
a module inside the actual application first, then insert a new class and
paste in the code, I can now save it (prompted for the class name of course)
and it saves in the application.

So it appears that the code that actually creates the class is creating it
inside of the Add-In container and it is illegal to save changes to that
from the app using the Add-In.

The odd part is that somehow, someway (and VERY briefly) at the very
beginning I was able to create the module in the application container and
MANUALLY save it by clicking the save icon.

Very frustrating.

Again, the code for creating the module is:

Function AddModule() As CodeModule
On Error GoTo Err_AddModule
Dim lVBCmp As VBComponent
    Set lVBCmp = mVBProj.VBComponents.Add(vbext_ct_ClassModule)
    Set mMdl = lVBCmp.CodeModule
    mMdl.Name = mstrClassName
    mMdl.CodePane.Show
    mMdl.AddFromString mstrModule
    Set AddModule = mMdl
Exit_AddModule:
On Error Resume Next
Exit Function
Err_AddModule:
        MsgBox Err.Description, , "Error in Function basVBE.AddModule"
        Resume Exit_AddModule
    Resume 0    '.FOR TROUBLESHOOTING
End Function

The mObjects are dimensioned in the header of the class, and mVBProj is
instantiated in the Init:

    Set mVBProj = CurrentProject.Application.VBE.ActiveVBProject

I thought that CurrentProject was the application and thus would cause an
instance of the application even if run in a lib or add-in.

John W. Colby
www.ColbyConsulting.com 


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.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