Removing macros from a document programmatically...

M

Meena Bhashyam

Hi,
I am trying to remove macros from my document with the following code:

For Each objComponent In objWordDoc.VBProject.VBComponents
If objComponent.Name <> "ThisDocument" Then
objWordDoc.VBProject.VBComponents.Remove objComponent
End If
Next
objWordDoc.Save

Somehow, when I open up the file by double-clicking on it, it asks me again
about disabling/enabling macros. However, when I try to view the macros, the
list is empty.

Would anybody be able to help me completely delete the macros?

Thanks,
Meena
 
G

Greg

Meena,

Try saving the docuement in RTF format, open, then save again in Word
format. This should remove the flag that is causing the message.
 
M

Meena Bhashyam

Greg,
Thank you for your response. Upon trying out what you suggested below, I
think the flag was reset, like you said, the list of macros was empty, but
the size of the file remained the same, as it would with a macro. Why would
this be?
 
G

Greg

Meena,

Sorry, I can't explain that. Did the process I suggested eliminate the
message that popped up?
 
M

Meena Bhashyam

Greg,
Yes, the process did remove the pop-up. Thank you for your help!
Meena
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top