Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Delete all modules and forms from workbook

Having difficulties posting - I fear I'm going to log on and see my question
8 times (please forgive me!).

Anyway, I want to delete all modules (about 20) and all forms (about 10) in
my workbook, and I am having great difficulty applying Chip Pearson's code.
I'm wondering if I don't have a necessary reference added - I continue to get
error messages.

Trying this line from Chip:
ThisWorkbook.VBProject.VBComponents("Module1").Nam e = "Module2"
returns this error:
"Programmatic access to Visual Basic Project is not trusted"

And this procedu
Sub DeleteModule()
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents("NewModule")
ThisWorkbook.VBProject.VBComponents.Remove VBComp
End Sub

returns this error:
"User-defined type not defined"

All my code is under the "Forms" folder and "Modules" folder, not under
sheets or "ThisWorkbook"

Can anyone see where I'm going wrong?

Thanks in advance
Daniel
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Delete all modules and forms from workbook

Hi Daniel,

"Programmatic access to Visual Basic Project is not trusted"


Tools | Macros | Security | Trusted publishers tab
check "Trust Access to Visual Basic Project"

"User-defined type not defined"


Chip Pearson's VBE prgramming page indicates:
'========================
Before using these procedures, you'll need to set a reference in VBA to the
VBA Extensibility library. In the VBA editor, go to the Tools menu, choose
the References item, and put a check next to "Microsoft Visual Basic For
Applications Extensibility" library. This enables VBA to find the
definitions of these objects. If you are using Excel97, this library will
appear in the References list without a version number: "Microsoft Visual
Basic For Applications Extensibility". If you are using Excel 2000 or 2002,
it will appear with a version number: "Microsoft Visual Basic For
Applications Extensibility 5.3". It is very important that you reference
the proper library. If you reference the wrong library, you will receive
"Type Mismatch" errors. If you don't reference the extensibility library at
all, you will receive "User Defined Type Not Defined Error".
'<========================


---
Regards,
Norman



"Daniel Bonallack" wrote in
message ...
Having difficulties posting - I fear I'm going to log on and see my
question
8 times (please forgive me!).

Anyway, I want to delete all modules (about 20) and all forms (about 10)
in
my workbook, and I am having great difficulty applying Chip Pearson's
code.
I'm wondering if I don't have a necessary reference added - I continue to
get
error messages.

Trying this line from Chip:
ThisWorkbook.VBProject.VBComponents("Module1").Nam e = "Module2"
returns this error:
"Programmatic access to Visual Basic Project is not trusted"

And this procedu
Sub DeleteModule()
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents("NewModule")
ThisWorkbook.VBProject.VBComponents.Remove VBComp
End Sub

returns this error:
"User-defined type not defined"

All my code is under the "Forms" folder and "Modules" folder, not under
sheets or "ThisWorkbook"

Can anyone see where I'm going wrong?

Thanks in advance
Daniel



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Delete all modules and forms from workbook

Thanks Norman. Poor research on my part.


"Norman Jones" wrote:

Hi Daniel,

"Programmatic access to Visual Basic Project is not trusted"


Tools | Macros | Security | Trusted publishers tab
check "Trust Access to Visual Basic Project"

"User-defined type not defined"


Chip Pearson's VBE prgramming page indicates:
'========================
Before using these procedures, you'll need to set a reference in VBA to the
VBA Extensibility library. In the VBA editor, go to the Tools menu, choose
the References item, and put a check next to "Microsoft Visual Basic For
Applications Extensibility" library. This enables VBA to find the
definitions of these objects. If you are using Excel97, this library will
appear in the References list without a version number: "Microsoft Visual
Basic For Applications Extensibility". If you are using Excel 2000 or 2002,
it will appear with a version number: "Microsoft Visual Basic For
Applications Extensibility 5.3". It is very important that you reference
the proper library. If you reference the wrong library, you will receive
"Type Mismatch" errors. If you don't reference the extensibility library at
all, you will receive "User Defined Type Not Defined Error".
'<========================


---
Regards,
Norman



"Daniel Bonallack" wrote in
message ...
Having difficulties posting - I fear I'm going to log on and see my
question
8 times (please forgive me!).

Anyway, I want to delete all modules (about 20) and all forms (about 10)
in
my workbook, and I am having great difficulty applying Chip Pearson's
code.
I'm wondering if I don't have a necessary reference added - I continue to
get
error messages.

Trying this line from Chip:
ThisWorkbook.VBProject.VBComponents("Module1").Nam e = "Module2"
returns this error:
"Programmatic access to Visual Basic Project is not trusted"

And this procedu
Sub DeleteModule()
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents("NewModule")
ThisWorkbook.VBProject.VBComponents.Remove VBComp
End Sub

returns this error:
"User-defined type not defined"

All my code is under the "Forms" folder and "Modules" folder, not under
sheets or "ThisWorkbook"

Can anyone see where I'm going wrong?

Thanks in advance
Daniel




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
Public, Private, Event modules, Forms modules,,, Jim May Excel Programming 11 October 31st 05 03:12 AM
Automatically Delete WorkBook 2 modules by using Workbook 1 module ddiicc Excel Programming 5 July 27th 05 12:53 PM
Forms and Modules scrabtree23[_2_] Excel Programming 4 November 11th 03 03:57 PM
Modules and Forms II Pedro Excel Programming 1 November 7th 03 11:19 AM
Modules and Forms Pedro Excel Programming 2 November 6th 03 02:02 PM


All times are GMT +1. The time now is 02:44 PM.

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

About Us

"It's about Microsoft Excel"