Solved

Bold the last word in vb

Posted on 2007-03-26
8
183 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now