selecting one line

J

Joanne

Usinv MSOffice Pro 2003 SP1
I want to select the first line of my document to capitalize it.
The line in the doc is not always the same length, so in my code here
that I generated with the macro recorder, line #3 uses wdCharacter and
Count:=15.
Selection.HomeKey Unit:=wdStory
Selection.EndKey Unit:=wdLine
Selection.MoveLeft Unit:=wdCharacter, Count:=15, Extend:=wdExtend
Selection.Font.AllCaps = wdToggle

What I really want is for this to select the entire line irregardless
of it's length. I was thinking to go to the end of the line and use
something like this:
Selection.MoveStartWhile cset:=" ", Count:=wdBackward
except that I don't want to move only until I hit a space, I want to
move back to the first character of the line and select all
characters.

Could you please help me solve this little issue
Much appreciation for your time and expertise
Joanne
 
J

Jonathan West

Joanne said:
Usinv MSOffice Pro 2003 SP1
I want to select the first line of my document to capitalize it.
The line in the doc is not always the same length, so in my code here
that I generated with the macro recorder, line #3 uses wdCharacter and
Count:=15.
Selection.HomeKey Unit:=wdStory
Selection.EndKey Unit:=wdLine
Selection.MoveLeft Unit:=wdCharacter, Count:=15, Extend:=wdExtend
Selection.Font.AllCaps = wdToggle

What I really want is for this to select the entire line irregardless
of it's length. I was thinking to go to the end of the line and use
something like this:
Selection.MoveStartWhile cset:=" ", Count:=wdBackward
except that I don't want to move only until I hit a space, I want to
move back to the first character of the line and select all
characters.

Could you please help me solve this little issue
Much appreciation for your time and expertise
Joanne

Hi Joanne,

This will do th needful

Sub T()
Selection.HomeKey Unit:=wdStory
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.AllCaps = wdToggle
End Sub

But beware. Once the text has been made all caps, it might be longer than a
line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top