dbTalk Databases Forums  

question:creating a new module with vb

comp.database.ms-access comp.database.ms-access


Discuss question:creating a new module with vb in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Fred Nobody
 
Posts: n/a

Default question:creating a new module with vb - 06-28-2003 , 07:30 AM






Hi
I'm trying to put together a set of tools for access 2002 and i would
like to create a module programmatically using vba but can't find any
documentation that leads me to believe this is possible. Is it?
TIA
epaulsen7 (AT) attbi (DOT) com

Reply With Quote
  #2  
Old   
Tom Wickerath
 
Posts: n/a

Default Re: question:creating a new module with vb - 06-28-2003 , 03:28 PM






Here is code that I was able to patch together that creates new modules,
however, I haven't quite figured out how to save the new module with a name
that I specify. The new module gets saved as ModuleX, where X = 1,2,3, etc.
This code is adapted from MSKB 223199, "ACC2000: Module Disappears After
Running Code":

http://support.microsoft.com/default...b;en-us;223199

I'm also not sure how useful this really is, because one would need to
somehow 1). add useful code to the module and 2). rename the module. Do you
know if there is a way of programmatically importing a saved module? If so,
you could create a text file and write whatever lines of code that you
wanted to in this text file, and then programmatically import it.

Good Luck!

Tom
_______________________________________________

Sub CreateMod()
' Code adapted from MSKB 223199, "ACC2000: Module Disappears After Running
Code"
' http://support.microsoft.com/default...b;en-us;223199
' Requires a reference to Microsoft Visual Basic for Applications
Extensibility <Version>

Dim myModule As Object
Dim strProjectName As String

strProjectName = CurrentProject.Name

' Remove the file extension from strProjectName
strProjectName = Left$(strProjectName, Len(strProjectName) - 4)

Set myModule = Application.VBE.VBProjects(strProjectName). _
VBComponents.Add(vbext_ct_StdModule)

DoCmd.Save acModule, myModule.Name
DoCmd.Close acModule, myModule.Name

End Sub

_______________________________________________

"Fred Nobody" <epaulsen7 (AT) attbi (DOT) com> wrote

Hi
I'm trying to put together a set of tools for access 2002 and i would
like to create a module programmatically using vba but can't find any
documentation that leads me to believe this is possible. Is it?
TIA
epaulsen7 (AT) attbi (DOT) com



Reply With Quote
  #3  
Old   
Tom Wickerath
 
Posts: n/a

Default Re: question:creating a new module with vb - 06-29-2003 , 05:34 AM



I just discovered that you had also posted your question to
comp.databases.ms-access (note the plural databases), and someone else
included an answer at that newsgroup. See
http://home.clara.net/tkwickenden/codeex/139.htm.


From: Pink Panther
Newsgroups: comp.databases.ms-access
Sent: Saturday, June 28, 2003 8:43 PM
Subject: Re: how to create a module in access 2002 with vb


Fred Nobody <epaulsen7 (AT) attbi (DOT) com> wrote

Quote:
Hi
I'm trying to put together a set of tools for access 2002 and i would
like to create a module programmatically using vba but can't find any
documentation that leads me to believe this is possible. Is it?
TIA
epaulsen7 (AT) attbi (DOT) com
docmd.RunCommand acCmdNewObjectModule
DoCmd.RunCommand acCmdNewObjectClassModule

will do the trick.

Check out http://home.clara.net/tkwickenden/

'conquering access RunCommand constants for some sample code.




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.