Case sensitive style names

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15581
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Case sensitive style names

Post by ChrisGreaves »

In this Microsoft.com thread of January 7, 2013 is a discussion of case [in]sensitive style names in MSWord. I have not progressed beyond Word2003.
When you assign a style to text using VBA, the lines
Selection.Style = "Heading 1"
and
Selection.Style = "heading 1"
have the same effect: both assign the built-in style "Heading 1" to the text. This also holds for custom styles: if you create a style named "tomato", but not a style named "TomaTo", the line
Selection.Style = "TomaTo"
assigns the "tomato" style to the text, you don't get an error message that "TomaTo" doesn't exist.
To date has anyone here any evidence that MSWord(any version) style names have been, or will be, case-sensitive?

I ask because I am about to force case-insensitivity on a style-searching function, as in "UCase everything in sight during the search".
Thanks
Chris
There's nothing heavier than an empty water bottle

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Case sensitive style names

Post by HansV »

As the OP in that thread remarked, it turns out that it is possible to create different styles named mystyle and MYSTYLE (and MyStyle etc.)

S0265.png

Although I still think this is a bug, you should not assume that style names are case-insensitive.
So you'd have to search twice: first, case-sensitive. If not found, then search case-insensitive.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
kdock
5StarLounger
Posts: 720
Joined: 21 Aug 2011, 21:01
Location: The beautiful hills of Western North Carolina

Re: Case sensitive style names

Post by kdock »

HansV wrote:
05 Apr 2021, 13:42
POTATO-potato.png
Let's call the whole thing off!
You do not have the required permissions to view the files attached to this post.
"Hmm. What does this button do?" Said everyone before being ejected from a car, blown up, or deleting all the data from the mainframe.

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Case sensitive style names

Post by HansV »

:laugh:
Best wishes,
Hans