VB Form in MS Word and Italics / Hyperlink

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chimichanga
    New Member
    • Jun 2010
    • 1

    VB Form in MS Word and Italics / Hyperlink

    Hi all,

    I'm sure this is a really basic question, but here goes anyway!

    I have a userForm with some text boxes / check boxes etc and when a user clicks the check box i would like some text to appear in MS Word via a bookmark. This is all working fine, but i would like part of the text paragraph to be in Italics and another part to be a hyperlink.

    For example, if i had the following sentence, i would like the word 'fox' to be italicised and the word http://www.lazydog.com to be a hyperlink:

    The quick brown fox jumps over the http://www.lazydog.com

    How do i make the word 'fox' italics and the other a hyperlink? In html, to make something italics you just surround the word with <I> Fox </I> or whatever, is there something similar in VB?

    No doubt its dead easy, but its driving me bonkers :)

    Thanks!
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    You want certain part of text in Word Doc to be Italisiced..?

    This, I have got from Macro Recording..:

    [code=vb]
    Selection.TypeT ext Text:="the quick "
    Selection.Font. Italic = wdToggle
    Selection.TypeT ext Text:="brown"
    Selection.Font. Italic = wdToggle
    Selection.TypeT ext Text:=" fox "
    ActiveDocument. Hyperlinks.Add Anchor:= _
    Selection.Range , Address:= _
    "http://www.temp.com", SubAddress:="", _
    ScreenTip:="", TextToDisplay:= "temp"
    Selection.TypeT ext Text:=" Continue text..."
    [/code]

    Regards
    Veena

    Comment

    Working...