E
Eager_Beever
I am a developer using Visual Basic 6. I have written a program where the
user enters some values to text boxes. Depending upon the values, a Word
document is created which displays the values entered along with descriptive
labels. None of the
fields/text boxes are compulsory and the output Word document contains only
those non-zero values. (That means I can not use predefined bookmarks to mark
locations. The resultant document will not contain a fixed no. of lines each
time). The user wants to apply bold formatting only to the values entered by
him and not to the descriptive labels. Both the labels and values are to be
printed on the same line (in plain and in bold format respectively). Also the
user wants that the values
should be printed in a separate font than the descriptive lables.
I have done everything else. I am able to create a Word document (.doc)
using Visual Basic with all the required contents. I am also able to apply
Bold and Underline formatting to an entire line. I am able to use different
fonts and font sizes to an entire line. But I am unable to apply bold
formatting only to a selected word from a line.
I need the document in the following format:
Today's Price : Rs. [125.00]
Available Qty : [10.250]
In the above output, the values enclosed within square braces should be in
Bold and in a different font, while everything else should be normal.
I will appreciate any type of help or suggestion on this. Thank You.
Eager_Beever
My code sample is as follows :
Dim objWord As Word.Application
Dim thisDoc As Word.Document
Dim thisRange As Word.Range
Set objWord = CreateObject("Word.Application")
Set thisDoc = objWord.Documents.Add
thisDoc.Range.InsertAfter "Today's Rates" & vbCrLf & vbCrLf
varLCount = thisDoc.Paragraphs.Count - 2
Set thisRange = thisDoc.Paragraphs(varLCount).Range
thisRange.ParagraphFormat.Alignment = wdAlignParagraphLeft
thisRange.Font.Name = "Verdana"
thisRange.Font.Size = 11
thisRange.Font.Bold = True
thisRange.Font.Underline = True
thisDoc.Range.InsertAfter " Today's Price : " & txtPrice.Text & vbCrLf
varLCount = thisDoc.Paragraphs.Count - 1
Set thisRange = thisDoc.Paragraphs(varLCount).Range
thisRange.ParagraphFormat.Alignment = wdAlignParagraphLeft
thisRange.Font.Name = "Verdana"
thisRange.Font.Size = 9
thisDoc.Range.InsertAfter " Available Qty : " & txtQty.Text & vbCrLf
varLCount = thisDoc.Paragraphs.Count - 1
Set thisRange = thisDoc.Paragraphs(varLCount).Range
thisRange.ParagraphFormat.Alignment = wdAlignParagraphLeft
thisRange.Font.Name = "Verdana"
thisRange.Font.Size = 9
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
thisDoc.SaveAs ("D:\Reports\Repo.doc")
objWord.Visible = True
user enters some values to text boxes. Depending upon the values, a Word
document is created which displays the values entered along with descriptive
labels. None of the
fields/text boxes are compulsory and the output Word document contains only
those non-zero values. (That means I can not use predefined bookmarks to mark
locations. The resultant document will not contain a fixed no. of lines each
time). The user wants to apply bold formatting only to the values entered by
him and not to the descriptive labels. Both the labels and values are to be
printed on the same line (in plain and in bold format respectively). Also the
user wants that the values
should be printed in a separate font than the descriptive lables.
I have done everything else. I am able to create a Word document (.doc)
using Visual Basic with all the required contents. I am also able to apply
Bold and Underline formatting to an entire line. I am able to use different
fonts and font sizes to an entire line. But I am unable to apply bold
formatting only to a selected word from a line.
I need the document in the following format:
Today's Price : Rs. [125.00]
Available Qty : [10.250]
In the above output, the values enclosed within square braces should be in
Bold and in a different font, while everything else should be normal.
I will appreciate any type of help or suggestion on this. Thank You.
Eager_Beever
My code sample is as follows :
Dim objWord As Word.Application
Dim thisDoc As Word.Document
Dim thisRange As Word.Range
Set objWord = CreateObject("Word.Application")
Set thisDoc = objWord.Documents.Add
thisDoc.Range.InsertAfter "Today's Rates" & vbCrLf & vbCrLf
varLCount = thisDoc.Paragraphs.Count - 2
Set thisRange = thisDoc.Paragraphs(varLCount).Range
thisRange.ParagraphFormat.Alignment = wdAlignParagraphLeft
thisRange.Font.Name = "Verdana"
thisRange.Font.Size = 11
thisRange.Font.Bold = True
thisRange.Font.Underline = True
thisDoc.Range.InsertAfter " Today's Price : " & txtPrice.Text & vbCrLf
varLCount = thisDoc.Paragraphs.Count - 1
Set thisRange = thisDoc.Paragraphs(varLCount).Range
thisRange.ParagraphFormat.Alignment = wdAlignParagraphLeft
thisRange.Font.Name = "Verdana"
thisRange.Font.Size = 9
thisDoc.Range.InsertAfter " Available Qty : " & txtQty.Text & vbCrLf
varLCount = thisDoc.Paragraphs.Count - 1
Set thisRange = thisDoc.Paragraphs(varLCount).Range
thisRange.ParagraphFormat.Alignment = wdAlignParagraphLeft
thisRange.Font.Name = "Verdana"
thisRange.Font.Size = 9
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
thisDoc.SaveAs ("D:\Reports\Repo.doc")
objWord.Visible = True