VBA code modules are normally attached to the template, not the document.
Unless you have deliberately added VBA components to the document itself,
you don't have a problem.
But in any case, you can refer to, and remove, the components of a VBA
project via the document's VBProject property --
with ActiveDocument.VBProject.VBComponents
.Remove .Item("Module1")
end with
I've never found a way to do that from VB or VBA. In principle you should be
able to use SendKeys to provide the password; I've never managed to get that
to work. Easier is to keep the code in the template or in an add-in; then
the problem doesn't arise in the first place.
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.