References bold/italic RRS feed

  • Question

  • Hi all,

    I want to develop an application that insert a reference correctly.

    I am new to VBA in Microsoft Word and want to ask if someone can help me out with this.
    What I want to do is that the user can click on a button so he gets a screen where he can fill in some fields and then press a button which will generate a paragraph after the cursor position.

    The screen and GUI is not the problem but I don't know how I can make just one word bold or Italic or something.
    Can someone help me out with this?

    Write a short example with just three words in it or something.

    Thank you!

    Sunday, October 19, 2014 12:31 PM


  • In the simplest form the example below will perform what you asked. There are additional things that you'd have to add before using it in production. For example adding a test about what the selected range actually is because if it was just a paragraph mark you probably wouldn't want to bold it.

    Sub SelectNextWord()
        Dim doc As Word.Document
        Set doc = ActiveDocument
        Selection.Collapse Word.WdCollapseDirection.wdCollapseEnd
        Selection.MoveEnd Unit:=Word.WdUnits.wdWord, count:=1
        Selection.Font.Bold = True
        Selection.Font.Italic = True
    End Sub

    Kind Regards, Rich ...

    Monday, October 20, 2014 11:02 AM