Solved

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

Posted on 2008-10-18
12
422 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
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
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…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
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 …

770 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