Accessing Word VBA project

P

Paul B

Using Word '03, I've noticed that when I open only one document,
I have VBA access to both that document's macro modules and those
of the normal.dot.

But when I open more than one document, the VBA editor will be
locked into the project that it initially gave focus to, and
macro projects of any other document, and that of normal.dot,
will be inaccessible. And that stays true even when all documents
are closed. The only way around it is to close and reopen Word
entirely.

I'm sure there's a security issue behind this behavior, but I
don't understand Ms's approach to the problem.

So my questions are two:

First, is there some way to circumvent this behavior? My macro
security setting is on Medium and I use the one instance of Word
option. I use a local certificate to sign my macro projects.

Second, lacking that, is there some way to have the first
document open giving the VBA project focus to normal.dot? That's
generally the project I want to keep access open to, and if the
focus starts there it will be maintained regardless of opening
other documents. Currently the focus is being given to the module
of the first-open document (oftentimes, it will have an autoexec
macro there; I'm not sure if that's the deciding factor in giving
the initial focus to the document rather than normal.dot or not).

Thanks,
p.
 
S

surfer5246

I notized that sometimes Project are not available, if the document was
opened via Explorer. They had to be open using Word. Second I think the
project that will be active/opened depends on witch Document was active
before you change to the VBA-Editor.
(I hope I had understand your question correctly, I'm not too good in English)
Pat
 
P

Paul B

I find the problem even when I open the docs via Word, as I do in
almost all cases.

Lately I've tried opening the VBA editor and activating the
normal.dot new macros module. But even with that, when I open a
second doc the focus in the VBA editor moves there and new macros
module goes inaccessible.

Sounds like you got the question right. Thanks for your input.
p.
 
S

surfer5246

Hi Paul
Sounds really bad; an error in (your) word? It should not behave like this.
All modules in the projects of all opened files should be accessible.
corrupt/destroyed normal.dot? Are there no Document_open macros in the file
you open? I would rename normal.dot in anything else; then start word, so
that a new normal.dot is created. Look if error still occurs. (If fine then
moving back my macrostuff piece by piece). If that not works I would try to
reinstall word.
Pat
 
P

Paul B

Hi Paul
Sounds really bad; an error in (your) word? It should not behave like this.
All modules in the projects of all opened files should be accessible.
corrupt/destroyed normal.dot? Are there no Document_open macros in the file
you open? I would rename normal.dot in anything else; then start word, so
that a new normal.dot is created. Look if error still occurs. (If fine then
moving back my macrostuff piece by piece). If that not works I would try to
reinstall word.
Pat

Ok, that's the first feedback I've gotten that this is not normal
behavior. I might have to go this route, though it will be
time-consuming, with macros, styles, and customizations.

I'll give it some thought and report back if I do it.

Thanks,
p.
 
P

Paul B

Hi Paul
Sounds really bad; an error in (your) word? It should not behave like this.
All modules in the projects of all opened files should be accessible.
corrupt/destroyed normal.dot? Are there no Document_open macros in the file
you open? I would rename normal.dot in anything else; then start word, so
that a new normal.dot is created. Look if error still occurs. (If fine then
moving back my macrostuff piece by piece). If that not works I would try to
reinstall word.
Pat

-I just finished a clean reinstall and MS update.
-Forced a new normal.dot.
-Added in a template with no macros (no other templates were loaded).
-Recorded a trivial macro to the added in template.
-Tried to access that macro in the VBA editor
-The project was locked.

At this point I have no idea what is going on. I found a previous
discussion of the problem and the consensus was a corrupted
normal.dot. But now I've gone way beyond that (and I also tried
Repair before the complete Reinstall), still to no avail.

My security certificate reads as OK, but I don't think that's a
factor getting into the VBA of a just-added-in template with a
brand new newmacros module.

p.
 
P

Paul B

-I just finished a clean reinstall and MS update.
-Forced a new normal.dot.
-Added in a template with no macros (no other templates were loaded).
-Recorded a trivial macro to the added in template.
-Tried to access that macro in the VBA editor
-The project was locked.

At this point I have no idea what is going on. I found a previous
discussion of the problem and the consensus was a corrupted
normal.dot. But now I've gone way beyond that (and I also tried
Repair before the complete Reinstall), still to no avail.

My security certificate reads as OK, but I don't think that's a
factor getting into the VBA of a just-added-in template with a
brand new newmacros module.

p.

One part of the mystery is cleared up. If I load extra templates
via the Global box, their code is inaccessible. But if the same
templates are added via the Attach Document Template box, there's
no problem.

I'm not sure why that is. And I've seen advice here that one
should keep macros in a add-in template. But if that makes their
code inaccessible that's not a good idea.

I'll have to monitor this for a while to see how it behaves when
simply opening more than one document under normal.dot.

Thanks, surfer, for your input.

p.
 
L

Lene Fredborg

Code stored in a template located in the Word Startup folder is accessible to
all documents, provided the add-in/global template is loaded (has a check
mark in the Templates and Add-Ins dialog box). This means that you will be
able to run macros from the template.

However, to be able to _edit_ the code of such template via the VBA editor,
you must open the template itself. Otherwise, you will see the message
“Project is unviewable†if you try to open the project of the template. When
you have opened the template itself, you can access the code unless it is
password-protected and you don’t know the password.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
P

Paul B

Code stored in a template located in the Word Startup folder is accessible to
all documents, provided the add-in/global template is loaded (has a check
mark in the Templates and Add-Ins dialog box). This means that you will be
able to run macros from the template.

However, to be able to _edit_ the code of such template via the VBA editor,
you must open the template itself. Otherwise, you will see the message
´Project is unviewable¡ if you try to open the project of the template. When
you have opened the template itself, you can access the code unless it is
password-protected and you donÿt know the password.


Yes, that was my experience. And since I often tweak one macro or
another (and I think the same dynamic holds true for keyboard
customizations), this strategy wasn't a good one for me.

Thanks,
p.
 

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