Results 1 to 11 of 11
  1. #1
    New Lounger
    Join Date
    Aug 2005
    Location
    Malaysia
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Option buttons to show relevant text (Word 2003)

    Hi everyone, I'm new here and I hope you guys can spend some of your precious time to guide me. Thanks in advance!

    I made a template that will pop up a dialog asking user to select some options. But then, I don't what to do next. My idea is when a user select OPTION A, a relevant text will be displayed. All options have different texts and it's a paragraph or two with font formatting. I'm not sure whether I should use the IF fields or write some IF..THEN...ELSE...codes in the VBA. As I'm not familiar with VBA and the correct way of using IF fields.
    Can someone please gude me? Thanks again!

    By the way, I didn't manage to read all the threads posted here (Sorry if I repeated the same issue) but only a few as it is too many of them. Maybe someone can point me some relevant threads if you came accross before. Tx!
    Attached Files Attached Files

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Option buttons to show relevant text (Word 200

    Are you planning to use this dialog in a special template? If so, it may be convenient to store the text you want to display as three AutoText entries. This gives you more flexibility with formatting than if you have VBA "type" the information into the document. Let's assume you have created three AutoText entries, at1, at2 and at3. In your OKButton's Click() procedure, you then can insert the text based on the user's choice. Here's some sample code:

    <code>Private Sub CommandButton1_Click()
    ' Insert AutoText for the selected option
    If Me.OptionButton1.Value = True Then
    ActiveDocument.AttachedTemplate.AutoTextEntries("a t1").Insert _
    where:=Selection.Range, RichText:=True
    ElseIf Me.OptionButton2.Value = True Then
    ActiveDocument.AttachedTemplate.AutoTextEntries("a t2").Insert _
    where:=Selection.Range, RichText:=True
    ElseIf Me.OptionButton3.Value = True Then
    ActiveDocument.AttachedTemplate.AutoTextEntries("a t3").Insert _
    where:=Selection.Range, RichText:=True
    End If
    ' The following can be done in the calling procedure...
    Unload Me
    End Sub</code>


    Does this approach work for your project?

  3. #3
    New Lounger
    Join Date
    Aug 2005
    Location
    Malaysia
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Option buttons to show relevant text (Word 200

    Thanks jscher2000!

    However, my concept is something like whenever a user opens this template, a pop up screen like the one I show previously will appear, user selects the option and the relevant text will appear. I'm not sure how to make this in AutoText, it seems autoText is very limited because the text I wanna show has a few paragraphs with title as well(a paragraph may consist of different font styles). This is only OPTION A. OPTION B and C has different style and format.
    What's the best way to do this?

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Option buttons to show relevant text (Word 200

    You can create quite complex autotext entries, with multiple paragraphs and formatting.

    Simply type the text, the way you want it to appear, into the document. Then select it and type Alt-F3, you will be promted to give this Autotext entry a name. Now you can delete this text from the document, and use a similar process to define your other two autotext entries.

    StuartR

  5. #5
    New Lounger
    Join Date
    Aug 2005
    Location
    Malaysia
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Option buttons to show relevant text (Word 200

    Thanks StuartR! Didn't know AutoText can be so useful.

    But I have another problem. If I'm using AutoText in this project, how am I going to edit a minor adjustment of the text? All the text are my sources, I might make some minor adjustment from time to time. Can it be done something like I save all the sources in a doc or dot file with easy update?
    I have seen HotDoc and AutoDoc before but somehow I can't afford it or in some cases, it can't fulfil my customization. Your help is greatly appreciated!

    Regards,
    ck

  6. #6
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Option buttons to show relevant text (Word 200

    Minor changes in Autotext are much easier than if you hard coded all the text and formatting in VBA.

    You can save the Autotext in a Global Template. When you need to change it you simply insert it into a document, edit it, and save it back to the Global Template again. You then need a process for updating the Global Template on all the user PCs (assuming that other people are using this code).

    If you are the only user, then it is easy, you just save the Autotext to Normal.dot and edit it as above.

    StuartR

  7. #7
    New Lounger
    Join Date
    Aug 2005
    Location
    Malaysia
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Option buttons to show relevant text (Word 200

    Thanks StuartR!
    I have some questions regarding this AutoText.
    1) Is that an easier way to transfer the Autotext from one template to another rather than recreate it again? Because I save in the wrong template.
    2) I've seen the preview column of AutoText. Can it been done using VBA in word? It seems the TextBox in the Toolbox only supports text and not graphics. So it will be easier when choosing the option and there's preview on it.

    ck

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Option buttons to show relevant text (Word 200

    Select Tools | Templates and Add-Ins...
    Click Organizer...
    Activate the AutoText tab.
    Open the source template (containing the AutoText) in the left hand pane (click Close File, then Open File)
    Open the target template in the right hand pane.
    Use the Copy>> button to transfer AutoText items.
    Attached Images Attached Images
    • File Type: png x.png (11.7 KB, 0 views)

  9. #9
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Option buttons to show relevant text (Word 200

    Hans has answered your Question 1.

    I'm afraid I have completely failed to understand your Question 2. Could you please clarify it a bit.

    StuartR
    (I am about to go to see a customer and may not return for a couple of days, hopefully someone will answer your questions before then)

  10. #10
    New Lounger
    Join Date
    Aug 2005
    Location
    Malaysia
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Option buttons to show relevant text (Word 200

    Thanks HansV! I guess I found the best forum ever.
    Any idea for my second question?

    ck
    Attached Images Attached Images

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Option buttons to show relevant text (Word 200

    I don't know how to show a preview on a userform. I'd use a description instead.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •