Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

But Bold and Enter key in a word document from vb.net

Status
Not open for further replies.

myrgir

Programmer
Feb 7, 2006
62
CA
Hi
I create a word file from vb.net (thanks to Sweep)

Now I would like to put a sentence in Bold, put an Enter key, and put the other sentence without Bold.
Here is my code
Code:
' Create invisible word application
        Dim wrd As Word.Application

        Try
            wrd = New Word.Application
            wrd.Visible = False
        Catch ex As Exception
            MsgBox("An error occured while printing, please try again")
        End Try

        ' Create a new document & range
        Dim doc As Word.Document = wrd.Documents.Add()
        Dim rng As Word.Range = doc.Range()

...
...
...

 For Each StringDr In StringDv
            Select Case StringDr("No")
                Case 500
                    rng.Text = StringDr("Message")

                    doc.Activate()
                    doc.CheckSpelling()
                Case 501
                    rng.Text = StringDr("Message")
                    doc.Activate()
                    doc.CheckSpelling()
 
Ok a little bit simplify,
How to put the first entry in bold and the other without bold.
Here is my code:
Code:
 For Each StringDr In StringDv
            Select Case StringDr("No")
                Case 500 '1.0
                    rng.Text = StringDr("Message")
                    doc.Activate()
                    doc.CheckSpelling()
                Case 501 '1.1
                    rng.Text = rng.Text + StringDr("Message")
                    doc.Activate()
                    doc.CheckSpelling()
               Case 502 '1.2
                    rng.Text = rng.Text + StringDr("Message")
                    doc.Activate()
                    doc.CheckSpelling()
End Select
        Next
        doc.SaveAs("c:\OperSeq.doc")

        wrd.Quit()

Thanks in advance!
 
Please, I really do need help.
Still don't know how to put my string in bold
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top