MatchCase

V

Vince

I have what appears to be a simple problem which I can't seem to solve:

Sample text:

dajkdjasjdsajdasdasdsa BOLD daskjdskdsad bold

* Please note that BOLD and bold are in bold.

Code:
with activedocument.range.find
.ClearFormatting

.Font.bold = True
.MatchWildcards = True
.MatchCase = True


With .Replacement

.text = ConversionsForm.TextBox5.text & "^&" &
ConversionsForm.TextBox4.text

End With

.Execute Replace:=wdReplaceAll

End With

ConversionsForm.TextBox5.text="<b>"
ConversionsForm.TextBox4.text="</b>"

When I execute this, this is what I get:

dajkdjasjdsajdasdasdsa <B>BOLD</B> daskjdskdsad <b>bold</b>

What I want is:
dajkdjasjdsajdasdasdsa <b>BOLD</b> daskjdskdsad <b>bold</b>

Of course, it's not the word BOLD I am after. I do not know the words that
will appear in bold which is why I've used wildcards.

I've played around with MatchCase and all that in vain. Can somebody please
tell me how to do this?

Thank you,

Vince
 
H

Helmut Weber

Hi Vince,

I think, some of the words you find are formatted as "All caps".
You have to treat this as just another kind of formatting,
you have to tag, just like bold. If there is no such tag,
you have to remove this formatting and convert the found string
to uppercase. I've been doing this kind of tagging 10 years,
Word to QuarkXpress, with more than 500,000 docs and the principle
is always:
Find a formatting, remove it, tag the found string.
Tagging can be done by replacement or by range.insertbefore
and range.insertafter.
Without removing the formatting, you may end up with
tags like <b><b><b>bold</b></b></b> if you try a second or third time.

HTH

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
V

Vince

Helmut,

Yet again, you've been of great help. Thanks a lot.

My principle was not correct. As you pointed out, I've changed it so it
removes the formatting soon as it's done tagging.

Ah, so you've already lived the tagging life for 10 years. We are supposed
to convert from Word to XML depending on the DTD. It's going okay (lists,
headings, references - I wrote a Perl program for that - and so on) but the
big problem is with tables which are in all sorts of "formats". The Row /
Column spanning is hard to detect and I can only get the <row> and <col>
(without spanning) done as per CALS. Well, anyway, that's another story!

Thanks a lot again!

Vince
 
H

Helmut Weber

Hi Vince,

I don't want to be obtrusive, but
I've changed it so it
removes the formatting soon as it's done tagging.

I recommended the other way round.
Remove the specific formatting first,
then do the tagging to make sure you get tags that do not carry
the formatting you were looking for.

By the way, the docs I apply Xpress tags to, are very
small and very simple.


Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
V

Vince

Hi Vince,

I don't want to be obtrusive, but


I recommended the other way round.
Remove the specific formatting first,
then do the tagging to make sure you get tags that do not carry
the formatting you were looking for.

By the way, the docs I apply Xpress tags to, are very
small and very simple.


Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"


Helmut,

Thanks! I actually coded it the right way (i.e.) Remove formatting, Do tagging
but wrote it the other way around in the post!

Our Docs are huge.. (Some run to 300 + pages)...

Vince
 

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