Programmatically create a new module 
Author Message
 Programmatically create a new module

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



Wed, 10 Dec 2003 21:03:38 GMT  
 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



Thu, 11 Dec 2003 00:58:01 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Creating a module programmatically

2. Programmatically Create new Access application ?

3. Help::Custom Field in programmatically creating new item

4. Programmatically create new document and NOT run AutoNew?

5. Creating new visual control programmatically?

6. Creating new forms programmatically?

7. Creating new visual control programmatically?

8. Create New records with a module

9. Creating new Access 97 database by VB code in Access 2000 module

10. Error on creating new module from addin

11. Creating a new instance of Winsock in a Class Module

12. programmatically editing a protected Access 2000 module

 

 
Powered by phpBB® Forum Software