PDA

View Full Version : First letter of a paragraph



Talis
07-02-2011, 02:28 PM
I'm using Word 2003

Description of problem:
Type 'The cat' (no quotes) into a new document.
Now do a Find/Replace -
Find: T
Replace: anywordinlowercase ^& anywordinlowercase

Execute the F/R

All the replacement takes on the case of the first letter, ie UPPERCASE.

Result:

'ANYWORDINLOWERCASE T ANYWORDINLOWERCASE'

When I want:

'anywordinlowercase T anywordinlowercase'

I'm using a F/R in VBA to locate text in bold and add tags but the tags become uppercase (undesirable) if the text is a single letter at the start of a paragraph.

I have tried deselecting the various Autocorrect options - to no avail.:banghead:

macropod
07-02-2011, 10:17 PM
Hi talis,

Have you checked the 'match case' option? No vba required.

Talis
07-03-2011, 12:59 PM
Paul, thank you for your reply.

When using the Find/Replace dialogue as follows it does work:
document: The cat
Find: empty, Match Case, Font: Bold
Replace: <b>^&</b> Font: Not Bold
Result: <b>T</b>he ca<b>t</b> - so that works OK - thanks for your tip
Note these are not the actual xhtml tags used

I must say I find that Match Case having this effect is illogical to me!

When I use the following subroutine it doesn't produce this same result:
Sub tagBold()
With ActiveDocument.Range.Find
.ClearFormatting
.Font.Bold = True
.MatchCase = True
.Text = ""
.Replacement.ClearFormatting
.Replacement.Text = "<b>^&</b>"
.Replacement.Font.Bold = False
.Forward = True
.Execute Replace:=wdReplaceAll
End With
End Sub

<b></b> appear as <B></B>
So that's where I need help for this problem.

Another thing I'm interested in is the line:

.Font.Bold = True

Is it possible to pass a variable to .Font so that it would be:
.Font.myStyle = True
in the above subroutine?
I suspect not, but would appreciate it being confirmed by an expert.

macropod
07-03-2011, 03:54 PM
Hi talis,

I must say I find that Match Case having this effect is illogical to me!
I can't imagine how else one might reasonably expect it to work.

Is it possible to pass a variable to .Font so that it would be:
.Font.myStyle = True
You could use '.Style = myStyle' for the Find expression or '.Replacement.Style = myStyle' for the Replace expression.