View Single Post
 
Old 04-12-2009, 05:21 AM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Lightbulb Code

The easiest way to do this would be to add a Message Box that Auto Opens with the document - this way the non savvy user only has to choose Yes or No and doesn't have to work out that they need to delete the button to prevent it appearing on the print out!

All you need to do is create a macro (record new macro) that inserts the text you need, and then replace the two lines of the code below (you may also want to change the Question and Title of the Script below, too!).

You would then open your Template, go to your VBA window (Alt+F11), Insert a new module and add the modified code. The upon open:

Word 2003 - if you have macro security at medium you will get a message asking to allow macros - upon clicking yes, the user will receive your question and can choose yes or no.

Word 2007 - you can save it as a macro embedded template and assign the stored area on the network as a trusted site, then it will just have the box pop-up each time as standard.

NOTE: your macro, if adding formatting/specific positioning, may be more than two lines like the one below - that's fine, just make sure you ONLY replace the two lines of code, the bottom lines MUST be placed after your (x) lines of code!


Code:
Sub AutoOpen()
    If MsgBox(Prompt:="Insert Text?", Buttons:=vbYesNo + vbQuestion, Title:="Insert formatted Text") = vbYes Then
           
        'The next two lines are the ones you need to replace with the results of your macro!
        Selection.TypeText Text:= _
            "This is my sample text - if you need it to be in a certain place, or format, then you will need to ensure that you do all formatting, placing, when you are recording your macro!"

        'KEEP THESE LINES OF CODE!!!
        Else
        Exit Sub
    End If
End Sub
Hope that helps kristinepjones :-)

Bird
Reply With Quote