Solved

Bold the last word in vb

Posted on 2007-03-26
8
189 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

730 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