Portable documents.

L

Len B

I have written a simple macro and stored it in the document, not in
normal.dot, because I want the macro to travel with the document to other
users. I want to make it easy for those users to be able to execute the code
using a simple method such as a keystroke combination or button click,
rather than using Tools, Macros, Run. For the same portability reason, I
also need to somehow avoid modifying Word's menus and toolbars.

Is there a preferred way of doing this? My searches of the help were
fruitless. I guess I am using the wrong search criteria. Can anyone point me
at a suitable resource?

TIA
 
R

Russ

Len,
The usual way is to create a template with all kinds of customizing in a
..dot file and have users open a new document based on that template.

But you can assign a keyboard shortcut to any macro.
In MacWord 2004, one way is through the menu Tool/Customize...Keyboard.

On the left side of the dialog select macros. Select your macro on the right
side and assign a keyboard shortcut combination. Make sure you select to
save changes to your document in the dropdown list before hitting the OK
button.
 
L

Len B

Thanks Russ.
That worked fine although the situation you described didn't apply. The
document is more like a log file and my macro finds the table, adds a row at
its bottom, inserts today's date and positions the cursor. Supplying a
custom template as well isn't appropriate.

If I could have the macro run when the document is opened, that would be
great but, as it is, they can press the keyboard shortcut for themselves.
Thanks again.
 
R

Russ

Try putting this sub with your other one in the document, hopefully it works
as expected when you first open the doc.
Sub AutoOpen()
MsgBox "The AutoOpen Ran this time"
End Sub
 
L

Len B

I tried it first on a fresh document and it failed. It obviously tried to
open and vba threw a msgbox saying macros disabled - check out host app.
(Macro Security is set to high.)

It also displayed 2 floating toolbars. One I recognize as the Control
Toolbox, 2 icon columns wide. It had the set square icon depressed and by
clicking on the cmd button, a new button appeared on the blank document
(i.e. it's active). The second toolbar is also 2 icon columns wide but has
only one icon - a set square, also depressed. The title bar only shows "Ex"
followed by the Add/remove buttons dropdown and the x to close the toolbar.
It is not resizable so I am unable to discover what the Ex stands for.
Clicking on View Toolbars doesn't show any beginning with Ex and there are
no strange ones ticked, just Standard, Formatting and Drawing. Do you know
what it is and what it's for? Deselecting its set square icon causes it to
vanish. Then the set square on the Control toolbox is no longer depressed
either. They must be connected in some way.

Signing the macro prevented this behaviour and the MsgBox succeeded,
Nevertheless, what is this phantom toolbox/bar and why throw me into design
mode?
 
R

Russ

I have no idea why it is thrown into design mode or what an Ex toolbar is. I
used that sub in my MacWord 2004 and it of course asked me to enable macros.
When I did it worked as expected. I figured you must have your other
document already authorized to run embedded macros by using the hotkey
method you mentioned. I, also, used a blank document for testing. I put the
macro in the This Document code panel of that document, only. Don't
accidentally put it in some other module, i.e. Normal.dot or any other .dot.

Do you know whether you are intercepting Word commands or events by naming
macros with special names, such as mentioned in this link?
 
L

Len B

Yes Russ,
The "real" document I had already signed. It was only the new blank (test)
document which got upset until I signed the macro. I was careful to store
the macro in the document itself, not in a .dot file. What fun it would be
to have every document autorun my macro. :-(

Thanks for the link. it was a fresh document and normal.dot has no such
macros. Nevertheless, I was unaware of these possibilities and so my
education improves. I guess the Ex box is one for the "Just another mystery"
file.
 

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