Solved

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

Posted on 2008-10-18
12
421 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Messed up my code 6 34
Running Visio Macro from VBS File 3 58
Automate switch config backup 3 46
Problem to open text file 11 73
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.

896 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

14 Experts available now in Live!

Get 1:1 Help Now