Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2009, 11:11 AM
kristinepjones kristinepjones is offline
Novice
Inserting paragraph into template option
 
Join Date: Apr 2009
Posts: 1
kristinepjones is on a distinguished road
Default Inserting paragraph into template option

Hello, I am making a template document for work. The template has several "optional" paragraphs. I was hoping I could place something into the doucment that, if clicked, the "option" is selected and certian text is inserted. If the employee chooses not to select that option, they can just delete the box entirely.



My thinking is that I can do this with a control command box... If clicked, I want the box to delete itself and, in its place within the word document, insert language saved in autotext.

Is this possible?

Is this the best way to do something like this?

Does anyone know how to insert the code for this type of command?

Quote:
Private Sub CommandButton1_Click()

End Sub
????

Lastly, can it be saved within a template (i.e., not only on my computer)?

Last edited by Bird_FAT; 05-20-2009 at 10:55 AM.
Reply With Quote
  #2  
Old 04-12-2009, 05:21 AM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Inserting paragraph into template option Inserting paragraph into template option 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
Reply

Tags
control command box, developer, insert optional paragraph, template

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting paragraph into template option can't delete paragraph mark at end of document kb Word 10 10-06-2017 02:32 PM
Inserting Pictures from File in Office 2003 pctech Office 1 02-20-2009 03:59 PM
Inserting paragraph into template option List option shashijb Excel 1 12-18-2008 03:07 AM
Paragraph Breaks In Mail Merge Fields SamuelT Mail Merge 0 09-25-2008 06:38 AM
Same As Previous - changing default when inserting/pasting LdeMarais Word 0 09-21-2007 11:07 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft