Display hidden text when document opens

R

Rick

Hello all!

I am a bit new to using VBA with Word, but pretty experienced in Microsoft
Access.

I have a word document that has some hidden text on the first page of the
document. It basically warns people not to make any changes to the document
if they don't understand how to do so without screwing up the formatting.
The problem is that some folks don't have the SHOW/HIDE Characters set to
show them. I tried going into VBA and entering 'ShowAll', but I'm not sure
how to tell Word to run that command when the document is opened.

Please help me with how to create a module that will ensure the text is
displayed. Alternately, I could have a box pop up that warns them using the
'msgbox' command, but I still need to figure out how to make this run when
the document is opened.

Thanks!!
 
J

Jean-Guy Marcil

Hi Rick;

Slap the following in the ThisDocument module of the template (if there is
one), or in the document's ThisDocument module:
'_______________________________________
Private Sub Document_Open()

ActiveDocument.ActiveWindow.View.ShowAll = True

End Sub
'_______________________________________

If the document is based on a template that contains that hidden text, and
you want that hidden text to be visible whenever a document is created form
the template, use this as well:
'_______________________________________
Private Sub Document_New()

ActiveDocument.ActiveWindow.View.ShowAll = True

End Sub
'_______________________________________


--
Cheers!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
R

Rick

I did as you suggested, and even tried putting a msgbox command in there as
weel. When I open the document nothing happens. It just opens as normal.
It is as though it does not know that the module is there.

Rick
 
R

Rick

Our corporate policy sets the macros to disabled (security = high) so the
code does not run. Is there any way to change this in the document?

Thanks!
 
C

Charles Kenyon

How about instead:

ActiveWindow.View.ShowHiddenText = True

This will not turn on paragraph mark or space display (which many users find
disconcerting).

--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
J

Jay Freedman

Hi, Rick,

The only macro code that can run when security = high is code in a template
that's installed in a "trusted" folder -- the Word Startup folder or the
User Templates folder, and then each user has to have "Trust all installed
add-ins and templates" checked in the security dialog. The other alternative
is to digitally sign the code and have everybody accept the certificate.

I'm constantly amazed at the number of people who ask about automatically
enabling their macros. Think about it for just a second -- if you could make
your macros enable themselves, so could every hacker who wants to run a
virus macro.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top