template that is global yet editable?

M

matt neuburg

I copied the stuff from my Normal template into a new template (called
GlobalTemplate) and deleted my Normal template so as to have a clean
Normal. I put GlobalTemplate into Office/Startup/Word.

Everything works, but GlobalTemplate is not editable with respect to
macros. I can't edit the macros that are in it. I can't even read them,
and I can't copy them into another template (VBA reports the template as
"locked" in some way, and the Organizer does not display its macros).
This is not what I was expecting.

So:

(1) Is this the way it's supposed to work? (I presume it is.)

(2) Is there a good way to make my macros globally available, *and* have
them be editable, *and* not live in Normal?

Thx - m.
 
P

Paul Berkowitz

I copied the stuff from my Normal template into a new template (called
GlobalTemplate) and deleted my Normal template so as to have a clean
Normal. I put GlobalTemplate into Office/Startup/Word.

Everything works, but GlobalTemplate is not editable with respect to
macros. I can't edit the macros that are in it. I can't even read them,
and I can't copy them into another template (VBA reports the template as
"locked" in some way, and the Organizer does not display its macros).
This is not what I was expecting.

So:

(1) Is this the way it's supposed to work? (I presume it is.)

(2) Is there a good way to make my macros globally available, *and* have
them be editable, *and* not live in Normal?

I have a few startup templates in Office/Startup/Word. (Actually I keep them
in the MUD folder and aliases in Office/Startup/Word, so they won't get lost
in an upgrade.) They're editable, and global. However, I made them there in
the first place, not in Normal.

So the problem must have arisen during the process of transferring them to
your new template. I'm presuming you used Organizer? There may have been
some property in the original Normal, or in the importing process, that made
the macros Read-Only. I don't know what that might be.

A way around this, had you known you would hit it in advance, might have
been to open the original Normal, open VB Editor, open the new template, and
copy and paste the macro code from Normal to the new Startup template,
rather than use Organizer. I don't think you should have to do this -
Organizer ought to work - but it would have worked.

How do you know that the macros are actually in the new template but that
you can't read them? What happens when you select the macro in VB Editor? Is
the "Edit" button dimmed? Do you get a "This document is locked" error
message?

I can't view the code in these Startup templates (I get the "locked"
message) unless I specifically open them first. Then open VB Editor. I can
select a Module in the Projects window in VBE, and View/Code (or F7), which
opens the module for reading and editing.

None of this should be Mac-specific. If you're sure the macros are in there
(perhaps they're in some other global template still on your computer, so
they'd still show up in the Macros list), you could ask in the
microsoft.public.word.vba.general newsgroup, which has some first-rate VBA
experts.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
M

matt neuburg

Paul Berkowitz said:
How do you know that the macros are actually in the new template but that
you can't read them? What happens when you select the macro in VB Editor? Is
the "Edit" button dimmed? Do you get a "This document is locked" error
message?

If I choose Tools > Macro > Macros, the macros are all listed as being
in GlobalTemplate. I can run them, but the Edit button is dimmed.

If I choose Tools > Macro > Visual Basic Editor, the GlobalTemplate
"project" is reported as locked.

In the Organizer, the GlobalTemplate macros are not shown.
I can't view the code in these Startup templates (I get the "locked"
message) unless I specifically open them first. Then open VB Editor. I can
select a Module in the Projects window in VBE, and View/Code (or F7), which
opens the module for reading and editing.

All of that is true for me too. But, as you know, that's not necessary
for macros that live in Normal. My question was: is there a place where
I can keep my macros such that (1) they are always available to be run,
(2) they are always available to be edited without opening the template
explicitly, and (3) they are not in Normal. It sounds like you are
saying there isn't... m.
 
D

Daiya Mitchell

(2) they are always available to be edited without opening the template
explicitly
It wasn't totally clear that "globally available" includes that....I
borrowed the suggestion of JE McGimpsey's that one keep global templates in
the Work menu to ease this hassle (which worked well, till I upgraded and
lost my Work menu. Clearly I'm going to have to finagle a macro workaround
for that).

DM
 
J

JE McGimpsey

All of that is true for me too. But, as you know, that's not necessary
for macros that live in Normal. My question was: is there a place where
I can keep my macros such that (1) they are always available to be run,
(2) they are always available to be edited without opening the template
explicitly, and (3) they are not in Normal. It sounds like you are
saying there isn't...

AFAIK, there isn't. As Daiya wrote, I keep my add-ins listed in my Work
menu to make it easier to open them to edit macros. I also use a macro
to load the add-in that menu, stored in a module within each add-in:

Public Sub AutoExec()
WorkMenuItems.Add ThisDocument
End Sub
 
J

JE McGimpsey

Daiya Mitchell said:
I borrowed the suggestion of JE McGimpsey's that one keep global
templates in the Work menu to ease this hassle (which worked well,
till I upgraded and lost my Work menu. Clearly I'm going to have to
finagle a macro workaround for that).

No need to finagle - make the add-in do the work. For each add-in that
you want to keep in the Work menu, put this in a regular code module
within the add-in:

Public Sub AutoExec()
WorkMenuItems.Add ThisDocument
End Sub

(Actually, I put it in a separate macro that I call from AutoExec(),
along with about 25 others that customize my environment.)

If the file already exists on the Work menu, the command is ignored.
Otherwise you can take the add-in from machine to machine and it will
always load itself into the Work menu.

Just because I'm a neat freak, I also remove the customizations when the
add-in closes:

Public Sub AutoExit()
DeleteWorkMenuItem
End Sub

Private Sub DeleteWorkMenuItem()
Dim i As Long
For i = 1 To WorkMenuItems.Count
With WorkMenuItems(i)
If ThisDocument.FullName = .Path & _
Application.PathSeparator & .Name Then _
.Delete
End With
Next i
End Sub
 
M

matt neuburg

JE McGimpsey said:
Daiya Mitchell said:
I borrowed the suggestion of JE McGimpsey's that one keep global
templates in the Work menu to ease this hassle (which worked well,
till I upgraded and lost my Work menu. Clearly I'm going to have to
finagle a macro workaround for that).

No need to finagle - make the add-in do the work. For each add-in that
you want to keep in the Work menu, put this in a regular code module
within the add-in:

Public Sub AutoExec()
WorkMenuItems.Add ThisDocument
End Sub

[etc.]

Cool, I think I'll try this too. Thx!

m.
 

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