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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing to word from vb6

Status
Not open for further replies.

vyper78

Programmer
Feb 5, 2004
30
AU
All

I have a vb app that opens a word doc and writes data to it, however, I am unable to change the size of the font nor make it bold. I find this odd as other functions such as italics and type of font work correctly. A snippet of my code is as follows:

<code>
dim WA as Word.Application
Set WA = GetObject("", "Word.Application")
If WA = "Nothing" Then ' True if not running
Set WA = CreateObject("Word.Application")
End If
WA.Visible = False

Set Doc = WA.Documents.Open(OpenPath)

Doc.Content.Select
With Doc.Application.Selection
.Font.Name = "Arial"
.Font.Size = 8
.Font.Italic = True
.Font.Bold = True
End With

WA.Doc.Content.Text = "This is some text"
</code>

Any help would be great.

cheers

K.
 
K.

1. Have you tried placing WA.Content.Text = "This ..." straight after Set Doc = WA.Doc..., then messing with the Font

2. also worth a try;

With Doc.Content.Font
.Name = "Arial"
.Size = 8
.Italic = True
.Bold = True
End With

may be shorter.

Regards Hugh,
 
Thanks for the reply Hugh

I'll give those ideas a go, however doesn't explain that the "italics" feature works and not the "bold". Anywho, I'll check it out and let you know.

V.
 
Mmm, figured out the problem. Seems that after my

WA.Doc.Content.InsertAfter = "This is some text"

I've got another statment making bold=false. Obviously this command determines font for the entire document.
So, my new question is, how can you make specific text/sentence bold.

I think I have to use "Range" to mark out some text, but am not too sure. Any ideas?

V.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top