Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default How to add New Module through coding

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_S tdModule)
VBComp.Name = "NewModule"
Application.Visible = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default How to add New Module through coding

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_S tdModule)
VBComp.Name = "NewModule"
Application.Visible = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default How to add New Module through coding

Sub AddModule()
Const vbext_ct_StdModule As Long = 1
Dim VBComp As Object
Set VBComp = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_S tdModule)
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" wrote in message
...
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_S tdModule)
VBComp.Name = "NewModule"
Application.Visible = True
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing a module by coding in VBA [email protected] Excel Programming 0 September 19th 07 04:38 PM
Coding to remove and import Module [email protected] Excel Programming 2 September 17th 07 10:21 PM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM
Run worksheet module code from workbook module? keithb Excel Programming 1 August 14th 05 04:04 AM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 10:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"