How can output the word “Status” in blue
and the word “Complete” in red?
Open “c:\windows\desktop\Report.doc” For Output As #1
Print #1, " Status:"
Print #1, " Complete"
Close #1
Thanks.
Printable View
How can output the word “Status” in blue
and the word “Complete” in red?
Open “c:\windows\desktop\Report.doc” For Output As #1
Print #1, " Status:"
Print #1, " Complete"
Close #1
Thanks.
You have to use OLE/ActiveX Automation, a sample is as follows:
Add a Reference to Microsoft Word 8.0(9.0 if Office 2K) Object Library
Code:Dim w As Word.Application
Set w = CreateObject("Word.Application")
w.Documents.Open ("C:\MyFile.doc")
w.ActiveDocument.Paragraphs.First.Alignment = wdAlignParagraphCenter
With w.ActiveDocument.Words(1) 'set first word
.Font.Size = 18
.Font.Color = wdColorBlue
.Text = "Status: "
End With
With w.ActiveDocument.Words(3) 'note skip, ":" is counted as a word
.Font.Size = 18
.Font.Color = wdColorRed
.Text = "Complete"
End With
w.ActiveDocument.Save
w.Visible = True