Solved

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

Posted on 2008-10-18
12
418 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
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:BethWoodhouse
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I do not think I worded my question well so that made it difficult.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
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:
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now