How do I make text bold?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rachel Hayes
    New Member
    • Jul 2010
    • 5

    How do I make text bold?

    I am using some code to copy database entries into a word document. I've defined some variables and then inserted these variables into the word document using bookmarks. Is there a way to make part of the variable appear in a bold font?

    Thanks
    Rachel
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    I've played with some code a little and have had limited success, but hopefully it will point you in the right direction.
    1. Declare a Modular Object Variable that will point to an Instance of Word.
      Code:
      Dim objWord As Word.Application
    2. Launch Word and Open C:\Test\Test.do c, Insert Text at a pre-defined Bookmark (Bookmark2), and Format the 1st 12 characters as BOLD.
      Code:
      Set objWord = New Word.Application
      
      objWord.Documents.Open "C:\Test\Test.doc"
      objWord.Visible = True
          
      'Insert Text at pre-defined Bookmark
      With objWord.ActiveDocument.Bookmarks
        .Item("Bookmark1").Range.Text = "Super_Dooper_Variable_Name"
           Selection.MoveRight Unit:=wdCharacter, Count:=12, Extend:=wdExtend
           Selection.Font.Bold = wdToggle
      End With
    3. Quit the Instance of Word, (not in the same Procedure), and set the Object Variable to Nothing
      Code:
      objWord.Quit
      Set objWord = Nothing

    Comment

    Working...