[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Making a title bold via VB6 then continuing in non-bold for the text

Posted on 2008-02-08
2
Medium Priority
?
1,183 Views
Last Modified: 2013-12-26
Experts,

Really simple - i want my title bold in a report i am autogenerating in word from a vb app.

Why isn't the below code working?:

Set appWord = CreateObject("Word.Application")
Set wrdDoc = appWord.Documents.Add
    wrdDoc.Sections.PageSetup.Orientation = Word.WdOrientation.wdOrientPortrait
Set oDoc = appWord.ActiveDocument
With appWord
   .WindowState = Word.WdWindowState.wdWindowStateMaximize
   Set wordRng = wrdDoc.Range
End With
wordRng.Font.Bold = True
wordRng.Font.Underline = wdUnderlineSingle
wordRng.Font.Size = 10

strPrint = "Time Sheet and Working Time Directive" & vbCrLf
wordRng.InsertAfter strPrint
wordRng.Font.Bold = False
wordRng.Font.Underline = wdUnderlineNone

Everything comes up times new roman size 10 but nothing in bold!

Thanks for your time experts!
0
Comment
Question by:MattAllen
2 Comments
 
LVL 13

Accepted Solution

by:
rettiseert earned 500 total points
ID: 20855675
Hi, you are setting the Font.Bold=False for the whole range, try this:

    Set appword = CreateObject("Word.Application")
   
    Set wrdDoc = appword.Documents.Add
        wrdDoc.Sections.PageSetup.Orientation = Word.WdOrientation.wdOrientPortrait
    Set oDoc = appword.ActiveDocument
    With appword
       .WindowState = Word.WdWindowState.wdWindowStateMaximize
       Set wordRng = wrdDoc.Range
    End With
    wordRng.Font.Bold = True
    wordRng.Font.Underline = wdUnderlineSingle
    wordRng.Font.Size = 10
   
    strPrint = "Time Sheet and Working Time Directive" & vbCrLf
    wordRng.InsertAfter strPrint
   
    Set wordRng = wrdDoc.Range(wrdDoc.Characters.Count - 1)
   
    wordRng.Font.Bold = False
    wordRng.Font.Underline = wdUnderlineNone
   
    wordRng.InsertAfter "TEST"
0
 

Author Closing Comment

by:MattAllen
ID: 31429386
Ahh so i have to keep re-setting the range every time i want to change a row / section / word to italic/bold/underlined/size etc.  Great stuff thanks!!
Cheers
Matt
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question