Word should allow intentional use of macros in other open docs

C

Curious_George

Excel allows me to run macros (via the macro dialogue) from any open excel
file. Word's macro dialog includes the option of "all open files and
templates" but does /not/ show macros in other open files.

While there are great reasons to use add-ins and templates (e.g. for
repetitive tasks), sometimes for single-use code it is easier just to use a
macro that works on "activedocument" and run it without the hassles of
teaching (novice) users about templates and template directories; if I help
write a quick macro for someone else who isn't PC literate, it is easier for
them to just open my document, press ALT-F8 and have run the code for their
document without having to install a global template for a one-time-only
macro. The dialog box seems to indicate that this was the original intent,
I'm just requesting that it be fixed so we can see and run macros in other
open documents.

Example: I write code to update all tables in activedocument, and I need to
run the same code for 8 files (one time only). I currently have to copy the
code into all 8 files, or save the code file as a template, locate my
template directory, save it there, restart word to add it in (or, save it
anywhere, then go to add-ins, find the file, load it) then run my macro.

All that work, when I've already got the code open and ready to run against
"activedocument". It would be better if I could just activate each document,
and run the code located in my first (still open) file.
Thank you!

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/com...8b9b3bd4&dg=microsoft.public.word.vba.general
 
D

Dave Lett

" I currently have to copy the code into all 8 files"
I don't think so.

Open all your documents and do something like the following:

Dim oDoc As Document
For Each oDoc In Documents
oDoc.Activate
'''your procedures
oDoc.Save
Next oDoc

HTH,
Dave
 
J

Jezebel

What utter nonsense. Just spend five minutes learning how Word manages
documents, templates, and code, and your problem will be gone.
 
E

Ed

Might this work?
-- Put your code in an AutoOpen macro in a document and give this document
to your users.
-- Code the macro to run on all open docs _except_ the one with the name of
your macro doc.
Dim strName As String
Dim x As Long, y As Long
x = Application.Documents.Count
For y = 1 To x
strName = Application.Documents(y).Name
If strName <> "MacroDoc.doc" Then
' Run code here
End If
Next y
-- Have your users open the necessary doc(s) first, and then open your macro
doc. Hopefully they are competent enough to understand that *only* the docs
to be affected are to be open.

HTH
Ed
 

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