Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Word to Prompt Upon Opening 1

Status
Not open for further replies.

BC000

Technical User
May 16, 2006
31
AU
When I create a document in word, I want the reader not to change any formating in the document. So, when someone opens the document, I would like a prompt to pop up saying: "Please do not alter formatting in any way" with Agree/Disagree buttons.

If the reader clicks on Agree, he/she gets to view the document, but if the reader clicks on Disagree the document should close.

I know I can achieve the same result by password protecting the document, but I would like to do it this way.

Can this be done by VB coding? Can someone please help?

Thanks in advance and Best Regards.

 
I don't want to make it read only, because different people have to add their stuff to the file.
 

Simplest way is an AutoOpen macro but, frankly, you're wasting your time. Anyone can disallow macros and just open the file without ever seeing, or agreeing to, anything.

If you want to remind people, it would probably be better to put a message (big and bold and red if you want) at the start of the Document.


Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Something I did some years ago was to make a template that had a AutoOpen macro. If I recall correctly, I think you can programicaly (sp?) control security from a macro. So if they tried to bypass the macro then they could not do anything. Of course this precludes the fact that someone with some VB background could figure out what I had done and bypass it.
 
Thanks.

Can you please let me know the code for the AutoOpen macro?
 
paste this into the ThisDocument code sheet...
Code:
Sub AutoOpen()
   msgbox "Hello world!"
End Sub
SaveAs your document as a MACRO ENABLED DOCUMENT.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 



You might want to do something like this, although it is not foolproof.

When the document closes, the FONT COLOR is changed to WHITE.

When the document opens, if MACROS are NOT enabled, the font remains WHITE. If, however, the MACROS ARE enabled, the font is changed to BLACK.
Code:
Sub AutoOpen()
    Dim rng
    With ThisDocument
        Set rng = Selection
        rng.WholeStory
        rng.Font.Color = vbBlack
    End With
End Sub

Private Sub Document_Close()
    Dim rng
    With ThisDocument
        Set rng = Selection
        rng.WholeStory
        rng.Font.Color = vbWhite
        .Save
    End With
End Sub

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
This is basically pointless. If they click Agree what is going to stop them from changing anything anyway?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top