Parse style names into alias segments?

B

Bear

I use a lot of this:

if objPara.Style = "LN" then...

But now I'm asked to add aliases to my standard set of styles. This will
break a lot of my code.

My first thought is to build a common function that will parse out each
segment of the style name, then evaluate each segment (Select Case), and pass
back the appropriate segment.

Does anyone have any code they'd like to share? I've explored Array, but
aliases aren't formatted that way.

Or is there a way to test a style that avoids this problem?

Bear
 
J

Jonathan West

Hi Bear,

This might do the needful

If Instr(objPara.Style & ",", ",LN,") > 0 Then ...

This works on the basis that somewhere within your new style name with all
the
aliases is your original vale. You need to ensure that you aren't matching a
part of another alias of a different style, hence the need to add a
terminating comma to the alias list, and match for the style name with
opening and closing commas added.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
B

Bear

Jonathan:

Thanks indeed. I had actually already hit on that as an emergency workaround
method, but wondered if it was "good coding" or not.

I like the idea of incorporating the comma delimiters in the comparison.

Bear
 
K

Klaus Linke

If the code is supposed to work in an international environment (which might
just be some users having set the MUI version to some menu/help language
other than English), the task can become an absolute beast.
The delimiters in alias names can turn into semicolons then, built-in styles
will take on the localized names, "Char" styles can be "Zchn" or "Car"
styles or whatever, ...
And you get a mix of all those names, depending on who edited the document
at some time in the past.

I've had cases where I wasn't able to access some styles by their name at
all. With all that renaming going on behind the scenes, it turned out
impossible to find (or guess) a name that works.

:-/ Klaus
 

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