Solved

Are macros in Normal.dot part of each Word document?

Posted on 2008-10-18
12
425 Views
Last Modified: 2012-05-05
I want to run many MS Word documents through the same macro (in VB script) but I do not want the documents to say "This document contains macros" when the end user tries to open the documents. Where should I put my macro?
0
Comment
Question by:BethWoodhouse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 22749896
Normally, Word macros remain in the template. You have to make a special effort to get them into the document.
Ideally the macros should be put into the template that you are going to create the document from. That could be the Normal template.
0
 

Author Comment

by:BethWoodhouse
ID: 22751283
The documents are created outside of Word  and I have to re-arrange the text somewhat and put them on an intranet for viewing.  I want the users to be able to open the documents in internet explorer without any message that "this document contains macros."  Therefore I do not want the macro attached to the word document but need to be able to call it from my vbscript.  

Sorry I missed the email about your response as it went directly to my junk email folder???
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 22751301
I don't fully understand your scenario, but if you get that message because of the macros in the attached template, then try attaching it to a template that does not contain macros.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 65

Expert Comment

by:RobSampson
ID: 22753646
Hi, to run a Word macro from VBS, you can do this.

Regards,

Rob.
strWordDoc = "\\server\share\myDoc.doc"
strMacroName = "MyMacro"
Set objWord = CreateObject("Word.Application")
objWord.DisplayAlerts = False
Set objDoc = objWord.Documents.Open(strWordDoc, False, False)
objWord.DisplayAlerts = True
objWord.Run strMacroName
objDoc.Close False
objWord.Quit

Open in new window

0
 

Author Comment

by:BethWoodhouse
ID: 22763108
Thanks Rob, that is about what I already have and it is working.  I have put my macro in normal.dot.  I am concerned about when I then put the document on the intranet (original document is saved on a different server for viewing), willl the users get a window asking if they want to allow macros to run? In other words, is the macro embedd in the document or completely as a seperate entity in normal.dot only ?
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22763125
Hi, the macro should still remain in the Normal.dot file, and it depends on the Macro Security level set by the user in Microsoft Word, as to whether they will receive the "allow macros" prompt.

Click Tools --> Macro --> Macro Security, and select Low, and you will not be prompted.

Regards,

Rob.
0
 

Author Comment

by:BethWoodhouse
ID: 22763502
I am aware of the way to avoid the question about macros but since there are many users out there that will be viewing these documents,  I do not want all of them ringing up as asking why they are getting this question about macros when all they want to do is view a document?
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 125 total points
ID: 22763600
Without knowing the current security settings, you'd need to look into signing the macro's, using Trusted Certificates, or placing the template with the macro into the StartUp folder.

See here for more information:
http://office.microsoft.com/en-us/ork2003/HA011403181033.aspx

Regards,

Rob.
0
 

Author Comment

by:BethWoodhouse
ID: 22763621
That sounds like what I need to know!  I will have a look and get back in touch but may not be untill tomorrow. Thanks, Beth
0
 
LVL 9

Expert Comment

by:jkunrein
ID: 22766941
As an aside, I'm going to assume that you are asking this because you want the code to run without the pesky "Enable Macro" box.  The previous comments address this quite well.

There is a sort of way to "force" a user into accepting your macros.  This is best done on a document-level, since the content changes from document to document, but the code is easy enough to copy.  

Open your document and select the entire range.  Define that as an AutoText.  Delete the range.  Type in instructions along the lines of, "In order to view this document, you must enable macros.  Please close this document and open it again.  Be sure you enable macros."  It could also help to explain how to trust your macros.

Create an AutoOpen macro (see snippet for a rough example) that deletes the entire contents of the document and inserts the AutoText.  The user then has two scenarios:
1. Disable macros and see a warning message that the document is not available.
2. Enable macros and see the desired document.  

As you can see, this has some narrow applications.  It only works to present information.  If the user enters information (such as a form), then the next time the document is opened, all that information is lost.  You could try to be clever and write code to copy all the new information into an AutoText when the document is closed (AutoClose).  

I don't know the exact scenario you are offering, so this suggestion may or may not be of use to you.
Public Sub AutoOpen()
    ActiveDocument.Range.Delete
    
    NormalTemplate.AutoTextEntries("IT WORKED").Insert Where:=Selection.Range, RichText:=True
 
End Sub

Open in new window

0
 

Author Comment

by:BethWoodhouse
ID: 22772591
Thanks, I will look at this soon but in the meantime, the job has another problem. I will be back!
Beth
0
 

Author Closing Comment

by:BethWoodhouse
ID: 31507477
I do not think I worded my question well so that made it difficult.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question