
Programmatically create a new module
Mike:
There's code below shows you how, it works with internal module adds or
external db module adds dependent on what objAccess is set to (here its the
current db, set it to an external target db by using CreateObject and
OpenCurrentDatabase):
HTH
--
Steve Arbaugh
ATTAC Consulting Group
http://ourworld.compuserve.com/homepages/attac-cg
'------------begin code------------------
Dim objAccess as Object
Dim objModule as Module
Set objAccess = Application.object
objAccess.DoCmd.RunCommand acCmdNewObjectModule
Set ObjModule = objAccess.Modules(objAccess.Application.CurrentObjectName)
ObjModule.InsertText "Your VBA Text Here"
objAccess.DoCmd.Close acModule, ObjModule, acSaveYes
objAccess.DoCmd.Rename "Your Module Name Here", acModule, ObjModule
objAccess.SysCmd 504, 16483 'Compile and save - undocumented, but works
though Access Xp
'---------------end code
Quote:
> Although it is fairly straight forward adding code to an existing module
is
> there any way to create a new module programmatically append it to an
> existing database and then add the code?
> Thanks in advance for any help