PC Review


Reply
Thread Tools Rate Thread

How to add New Module through coding

 
 
=?Utf-8?B?a3Jpcw==?=
Guest
Posts: n/a
 
      19th Nov 2007
I am trying the following but getting error messages, please help

Sub AddModule()
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_StdModule)
VBComp.Name = "NewModule"
Application.Visible = True
End Sub
 
Reply With Quote
 
 
 
 
=?Utf-8?B?YnJvcm8xODM=?=
Guest
Posts: n/a
 
      19th Nov 2007
hi Kris,

Your code looks like it is the same as some on Chip Pearson's below page:
http://www.cpearson.com/excel/vbe.aspx

At the very top of this page Chip states "In order to use the code on this
page in your projects, you must change two settings....", check it out &
hopefully it will solve your problem.
Note, Chip also has a red warning box discussing virus scanners & how they
may delete modules that reference a VBProject object.

hth
Rob

__________________
Rob Brockett
NZ
Always learning & the best way to learn is to experience...


"kris" wrote:

> I am trying the following but getting error messages, please help
>
> Sub AddModule()
> Dim VBComp As VBComponent
> Set VBComp = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_StdModule)
> VBComp.Name = "NewModule"
> Application.Visible = True
> End Sub

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      19th Nov 2007
Sub AddModule()
Const vbext_ct_StdModule As Long = 1
Dim VBComp As Object
Set VBComp = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_StdModule)
VBComp.Name = "NewModule"
Application.Visible = True
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"kris" <(E-Mail Removed)> wrote in message
news:1EA2285F-6C25-4066-A1E5-(E-Mail Removed)...
>I am trying the following but getting error messages, please help
>
> Sub AddModule()
> Dim VBComp As VBComponent
> Set VBComp = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_StdModule)
> VBComp.Name = "NewModule"
> Application.Visible = True
> End Sub



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing a module by coding in VBA mathieu936@gmail.com Microsoft Excel Programming 0 19th Sep 2007 04:38 PM
Coding to remove and import Module mathieu936@gmail.com Microsoft Excel Programming 2 17th Sep 2007 10:21 PM
module coding in query =?Utf-8?B?UnVzcw==?= Microsoft Access Queries 1 1st Jul 2006 12:19 PM
forms coding to module (Urgent) =?Utf-8?B?SWFuIEI=?= Microsoft Access Form Coding 2 11th Aug 2005 03:46 PM
Module coding Lurch Microsoft Access Forms 2 26th Mar 2004 02:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:08 AM.