
delete all code modules using VBA
This is the code that worked:
For each myComponent in ActiveDocument.VBProject.VBComponents
If myComponent.Type = vbext_ct_ClassModule or _
myComponent.Type = vbext_ct_ClassModule or _
myComponent.Type = vbext_ct_ClassModule Then
Call Application.OrganizerDelete(ActiveDocument.Name, _
myComponent.Name,
_
wdOrganizerObjectProjectItems)
End If
Next myComponent
When I save the resulting doc and re-open it, Word still thinks it has
macros.
If I say "okay, enable macros", I don't see anything in the project window .
. .
If anyone can answer this one ... thanks!
Lisa
Quote:
> In Word 2000, I have the following code to delete all code modules from a
> document -- so I can
> ensure that all macros are removed before I distribute it.
> For each myComponent in ActiveDocument.VBProject.VBComponents
> If myComponent.Type = vbext_ct_ClassModule or myComponent.Type =
> vbext_ct_StdModule Then
> ActiveDocument.VBProject.VBComponents.Remove (myComponent)
> End If
> Next myComponent
> The VBA object browser gives the signature for VBComponents.Remove as
> Remove(VBComponent As VBComponent)
> But when I run the code, I get the following error on the Remove method:
> Run-time error '438' Object does not support this property or method
> I've inspected the VBComponents and the code is attempting to remove the
> code module, just as I intended.
> Any ideas what's up? Thanks for any help!
> Lisa