Results 1 to 5 of 5

Thread: Writing formatted text at a bookmark in Word

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Location
    Cork, Ireland
    Posts
    14

    Writing formatted text at a bookmark in Word

    I been going over a few of the posts on opening Word documents and writing to them at a Bookmark through VB.NET and I have that working OK. What I would like to do is use bold and underlining formatting (and more no doubt)

    At the top of the class I have
    Code:
    Private WordApp As New Word.Application
    and the main code is:
    Code:
    Dim fileName As Object = "C:\Proposal.doc"
            Dim [readOnly] As Object = False
            Dim isVisible As Object = True
    
            Dim missing As Object = System.Reflection.Missing.Value
    
            Dim WordDoc As New Word.Document
    
            WordApp.Visible = True
            WordDoc = WordApp.Documents.Open(fileName, missing,
    [readOnly], missing, missing, missing, missing, missing, missing,
     missing, missing, isVisible)
    
            WordApp.Activate()
    
            WordDoc.Bookmarks.Item("MyBookmark").Range.Text = "I am a line of text"
    If I were to start typing at the start of the document the following works:
    Code:
    WordApp.Selection.Font.Bold = True
            WordApp.Selection.TypeText("Bold Text")
            WordApp.Selection.Font.Bold = False
    but I can't this working at the bookmark.

    Help much appreciated
    Last edited by chakotha; Mar 12th, 2004 at 10:24 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width