Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Word should allow intentional use of macros in other open docs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Curious_George - 16 Aug 2006 18:51 GMT
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!
Dave Lett - 16 Aug 2006 18:58 GMT
" 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

> 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
[quoted text clipped - 39 lines]
>
> http://www.microsoft.com/office/community/en-us/default.mspx?mid=e0921c90-7c55-4
00c-8b00-95ad8b9b3bd4&dg=microsoft.public.word.vba.general
Jezebel - 16 Aug 2006 22:26 GMT
What utter nonsense. Just spend five minutes learning how Word manages
documents, templates, and code, and your problem will be gone.

> 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
[quoted text clipped - 39 lines]
>
> http://www.microsoft.com/office/community/en-us/default.mspx?mid=e0921c90-7c55-4
00c-8b00-95ad8b9b3bd4&dg=microsoft.public.word.vba.general
Ed - 16 Aug 2006 22:35 GMT
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

> 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
[quoted text clipped - 39 lines]
>
> http://www.microsoft.com/office/community/en-us/default.mspx?mid=e0921c90-7c55-4
00c-8b00-95ad8b9b3bd4&dg=microsoft.public.word.vba.general
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.