ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Removing macros using VBA (https://www.excelbanter.com/excel-programming/308656-re-removing-macros-using-vba.html)

Norman Jones

Removing macros using VBA
 
Hi Jgranda,

In the VBE | Tools | References | find and check the Visual Basic For
Applications Extensibility library.

---
Regards,
Norman



"jgranda" wrote in message
...
I am using the code from the pearson website but there is a case of user
error - me.

I am receiving the following error message:
"Compile error: User-defined type not defined"

The code I am using is:
Sub DeleteModule()
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents("Module1")
ThisWorkbook.VBProject.VBComponents.Remove VBComp
End Sub

When I run the debugger, it is highlighting the line Dim VBComp As
VBComponent.

Can someone give me advice on how to correct?

Thanks,

Joe




Bob Phillips[_6_]

Removing macros using VBA
 
Change this line

Dim VBComp As VBComponent

to

Dim VBComp As Object

no need for a reference then.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"jgranda" wrote in message
...
Thank you for that information regarding references. I do not have

"Visual
Basic for Applications Extensibility Library" listed. I have "Visual

Basic
for Applications" checked but there are also several other "Visual Basic

for
Applications" unchecked with no descriptions on the differences. How do I
add the Extensibility Library?

"Norman Jones" wrote:

Hi Jgranda,

In the VBE | Tools | References | find and check the Visual Basic For
Applications Extensibility library.

---
Regards,
Norman



"jgranda" wrote in message
...
I am using the code from the pearson website but there is a case of

user
error - me.

I am receiving the following error message:
"Compile error: User-defined type not defined"

The code I am using is:
Sub DeleteModule()
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents("Module1")
ThisWorkbook.VBProject.VBComponents.Remove VBComp
End Sub

When I run the debugger, it is highlighting the line Dim VBComp As
VBComponent.

Can someone give me advice on how to correct?

Thanks,

Joe







Norman Jones

Removing macros using VBA
 
Hi Jgranda,

The library name should be:

Microsoft Visual Basic for Applications Extensibility Library.

Note the initial Microsoft. On my system the version number is 5.3


---
Regards,
Norman



"jgranda" wrote in message
...
Thank you for that information regarding references. I do not have
"Visual
Basic for Applications Extensibility Library" listed. I have "Visual
Basic
for Applications" checked but there are also several other "Visual Basic
for
Applications" unchecked with no descriptions on the differences. How do I
add the Extensibility Library?

"Norman Jones" wrote:

Hi Jgranda,

In the VBE | Tools | References | find and check the Visual Basic For
Applications Extensibility library.

---
Regards,
Norman



"jgranda" wrote in message
...
I am using the code from the pearson website but there is a case of user
error - me.

I am receiving the following error message:
"Compile error: User-defined type not defined"

The code I am using is:
Sub DeleteModule()
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents("Module1")
ThisWorkbook.VBProject.VBComponents.Remove VBComp
End Sub

When I run the debugger, it is highlighting the line Dim VBComp As
VBComponent.

Can someone give me advice on how to correct?

Thanks,

Joe







David

Removing macros using VBA
 
?B?amdyYW5kYQ==?= wrote

Thank you for that information regarding references. I do not have
"Visual Basic for Applications Extensibility Library" listed. I have
"Visual Basic for Applications" checked but there are also several
other "Visual Basic for Applications" unchecked with no descriptions
on the differences. How do I add the Extensibility Library?


I see what you see, one at the top and several way down the list. The only
way I know I've checked the right one is to follow the path listed for
Location: under that list (path is chopped, but what you can see will get
you to the right folder). The file name you're looking for is VBE6EXT.OLB
(intuition?). If you right click on that file, click Properties and the
Version tab, you'll see:
Visual Basic for Applications Extensibility Library
(actually it's chopped, but logically couldn't be otherwise)
in the Description: field

This is using XL2000, so filename with other versions may differ (guess).
Don't know why it's showing up the way it is in References. Seems to me I
read a long time ago there was a way to fix that so the full name would
show -- too long ago to worry about now, though, if even there were a way.

--
David


All times are GMT +1. The time now is 05:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com