Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Parse style names into alias segments?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bear - 21 Feb 2006 16:00 GMT
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
Jonathan West - 21 Feb 2006 16:19 GMT
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.

Signature

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

>I use a lot of this:
>
[quoted text clipped - 14 lines]
>
> Bear
Bear - 21 Feb 2006 17:55 GMT
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

> Hi Bear,
>
[quoted text clipped - 27 lines]
> >
> > Bear
Klaus Linke - 22 Feb 2006 15:25 GMT
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

> Jonathan:
>
[quoted text clipped - 42 lines]
>> >
>> > Bear
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.