473,394 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How do I make text bold?

I am using some code to copy database entries into a word document. I've defined some variables and then inserted these variables into the word document using bookmarks. Is there a way to make part of the variable appear in a bold font?

Thanks
Rachel
Aug 4 '10 #1
1 4905
ADezii
8,834 Expert 8TB
I've played with some code a little and have had limited success, but hopefully it will point you in the right direction.
  1. Declare a Modular Object Variable that will point to an Instance of Word.
    Expand|Select|Wrap|Line Numbers
    1. Dim objWord As Word.Application
  2. Launch Word and Open C:\Test\Test.doc, Insert Text at a pre-defined Bookmark (Bookmark2), and Format the 1st 12 characters as BOLD.
    Expand|Select|Wrap|Line Numbers
    1. Set objWord = New Word.Application
    2.  
    3. objWord.Documents.Open "C:\Test\Test.doc"
    4. objWord.Visible = True
    5.  
    6. 'Insert Text at pre-defined Bookmark
    7. With objWord.ActiveDocument.Bookmarks
    8.   .Item("Bookmark1").Range.Text = "Super_Dooper_Variable_Name"
    9.      Selection.MoveRight Unit:=wdCharacter, Count:=12, Extend:=wdExtend
    10.      Selection.Font.Bold = wdToggle
    11. End With
  3. Quit the Instance of Word, (not in the same Procedure), and set the Object Variable to Nothing
    Expand|Select|Wrap|Line Numbers
    1. objWord.Quit
    2. Set objWord = Nothing
Aug 4 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Imaya Kumar | last post by:
Hi, i'm developing an editor in VS.NET using Rich Text Box Control. I need to make a selected text Bold. how can i do this? also i will have an Italic Button too. If i click Bold button the...
6
by: Ronny sigo | last post by:
Hello all, I have made a form with a lot of entryfields and one button which, when clicked on, transforms all of the entryfields values into a MS Word document. All the formatting is done...
1
by: Piotrek Stachowicz | last post by:
Hi, Does anyone know if there is any way to display text in ToolTip as bold or italic? If so, how?! Piotrek
6
by: Radith Silva | last post by:
I have the following code: Private Sub Bold(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuFileBold.Click If mnuFileBold.Checked = True Then mnuFileBold.Checked = False...
3
by: Rich | last post by:
Could someone share how to toggle the font property of a label from regular to bold and back to regular? I have tried label.Font.Bold = True but get the error message that this property is...
1
by: ahmad | last post by:
I want to make a particular option's text bold within a list in html, while all other options will get their normal font-weight, How can i do this???????? i tried <b>, <font> tags and style and...
2
by: Rex | last post by:
Hi, I want to make a particular piece of text BOLD (during runtime) in a textbox. for example: consider a string "The next stage for plaque collection will be at the end of January". I want to...
5
by: cs_hart | last post by:
I have an app that sends email to clients. There is now a requiremnt to have one line in bold, as some clients seem to have overlooked some instruction. Right now the body is just a bunch of...
1
by: Apolakkiatis | last post by:
Property 'Bold' is 'ReadOnly'. << this error occurs when i type Textbox2.Font.Bold = True What am i doing wrong??? I have vb08..
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.