Re: VBA to remove modules in .DOT

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Had a bit of trouble with my news reader... but Success on the Word
front!

To Perry (and anyone else interested):

I did the following and I like what it does for me (on first test
anyway).
This doesn't remove anything from the .DOT -- it just breaks any
association between the .DOC and the "master" .DOT.

This works for me because now the VBA code maros are not in any way tied
to
the .DOC.

Happy April to all,
Warren

Needmo Smarts <not_here@xxxxxxxxxxxx> wrote in
news:Xns9634D8E999B62xkxnxaxuxex@xxxxxxxxxxxxxx:

> Perry,
> Thanks for hanging in there & providing help.
> You are somewhat over my head--I don't know anything about the VBA
> Extensibility lib 53. I am using Word 2000 and have no other VB
> product. I will try using the Subs you've provided when I get the
> chance this week at work (BIG assumption!) Looks like I'll need to
> declare and use an object representing the current document...
>
> Thanks,
> Warren
>
> "Perry" <DrumProgrammer@xxxxxxxxxxx> wrote in
> news:#OWq93bPFHA.1564@xxxxxxxxxxxxxxxxxxxx:
>
>> Add a reference in VBE pointing to: Microsoft VBA Extensibility lib
>> 53 Two examples removing either a module "MYModule" or a macro
>> "MyMacro" from a document represented by object variable:
>> "TargetDocument"
>>
>> Sub DeleteProcedure()
>> Dim vbc As VBComponent
>> Set vbc = TargetDocument.VBProject.VBComponents("MYModule")
>> With vbc.CodeModule
>> .DeleteLines .ProcStartLine("MyMacro", vbext_pk_Proc), _
>> .ProcCountLines("MyMacro", vbext_pk_Proc)
>> End With
>> End Sub
>>
>> Sub DeleteModule()
>> Dim vbc As VBComponent
>> Set vbc = TargetDocument.VBProject.VBComponents("MYModule")
>> ThisDocument.VBProject.VBComponents.Remove vbc
>> End Sub
>>
>>
>> Krgrds,
>> Perry
>>
>

.



Relevant Pages

  • Re: VBA to remove modules in .DOT
    ... Perry, ... You are somewhat over my head--I don't know anything about the VBA ... > Add a reference in VBE pointing to: Microsoft VBA Extensibility lib 53 ... > Sub DeleteProcedure() ...
    (microsoft.public.word.vba.beginners)
  • Re: VBA to remove modules in .DOT
    ... Sub Document_Close ... > To Perry: ... >>> Dim vbc As VBComponent ...
    (microsoft.public.word.vba.beginners)
  • Re: Bias in rand for excel 07
    ... that was statistically different from expectation. ... Sub SimplerVersion() ... "yttrias" wrote: ... There is no RANDfunction in VBA. ...
    (microsoft.public.excel.programming)
  • Re: Bias in rand for excel 07
    ... F1 with a dynamic formula that will update whenever the RAND() functions ... Sub SimplerVersion() ... "yttrias" wrote: ... There is no RANDfunction in VBA. ...
    (microsoft.public.excel.programming)
  • Re: merging documents into templates - automation problem
    ... The code to launch ... Private Sub UserForm_Initialize ... UserForm_Initialize is an EVENT for the UserForm, called by VBA when the ... the code is in a code module for a form. ...
    (microsoft.public.office.developer.automation)