Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2007

Tip: Looking for answers? Try searching our database.

inserting two text blocks with different formats in Word from Excel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ajaypondicherry@gmail.com - 24 Jan 2007 00:31 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
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.