Solved

Bold the last word in vb

Posted on 2007-03-26
8
186 Views
Last Modified: 2010-04-30
I know this will bold the last line:

myDOc.Sentences.Last.Bold = True

How can I bold the last "word"
0
Comment
Question by:al4629740
  • 3
  • 2
  • 2
8 Comments
 
LVL 32

Expert Comment

by:Daniel Wilson
ID: 18799458
Is this in MS Word?  What version?
0
 

Author Comment

by:al4629740
ID: 18800031
yes, ms word 2003
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 18800887
myDOc.Sentences.Words(myDOc.Sentences.Words.count-1).Bold = True
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 26

Assisted Solution

by:EDDYKT
EDDYKT earned 200 total points
ID: 18800893
myDOc.Sentences.Last.Words(myDOc.Sentences.Last.Words.count-2).Bold = True
0
 

Author Comment

by:al4629740
ID: 18802620
I get "data member not found.."  Why is this happening?
0
 

Author Comment

by:al4629740
ID: 18948856
I tried:
myDOc.Words.Last.Bold = True

But it does not do anything.  Why Not?????
0
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 300 total points
ID: 18949710
How many carriage returns or page breaks do you have after your "last" word?

Trying EDDYKT's script above, I found that it worked right when I had a return after my last word.  When I deleted that return the next-to-last word was what was bolded.  

I find that myDoc.Words.Last evaluates to a return.  What's working for me is:
ThisDocument.Words.Item(ThisDocument.Words.Count - 1).Bold = True
   
(Besides EDDYKT's code).
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

773 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