I am creating a Microsoft Excel Spreadsheet which launches a Word Doc
and would like to make a document title in a certain format and below
it make the body text with another format. It seems as if both texts
always use the same formatting. Below is a section of my code.
With mywdRange
.Text = Range("F6") & " Title" & " Text"
.Font.Name = "Comic Sans MS"
.Font.Size = 20
.Bold = True
End With
With mywdRange
.Text = Range("F6") & " Body" & " Text"
.Font.Name = "Comic Sans MS"
.Font.Size = 12
.Bold = False
End With
Jonathan West - 24 Jan 2007 11:19 GMT
>I am creating a Microsoft Excel Spreadsheet which launches a Word Doc
> and would like to make a document title in a certain format and below
[quoted text clipped - 14 lines]
> .Bold = False
> End With
Both bits of code appear to be operating on the same range. Is there some
other bit of code between them that you haven't shown us, where the location
pointed to by mywdRange changes?

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
Doug Robbins - Word MVP - 24 Jan 2007 12:44 GMT
I would create document variables to contain the text and then have it
appear in the required places in the documnet by use of DOCVARIABLE fields
to which you add the \*charformat switch if necessary to get the desired
format.
With ActiveDocument
.Variables("docvar1").Value = Range("F6") & " Title Text"
.Variables("docvar1").Value = Range("F6") & " Body Text"
.Fields.Update
End With

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
>I am creating a Microsoft Excel Spreadsheet which launches a Word Doc
> and would like to make a document title in a certain format and below
[quoted text clipped - 14 lines]
> .Bold = False
> End With