Case sensitive style names

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 12334
Joined: 24 Jan 2010, 23:23
Location: paused.undefined.exposed

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
In Physics you don't get anything for nothing
In Yorkshire you don't get owt for nowt

User avatar
HansV
Administrator
Posts: 72003
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.
Regards,
Hans

User avatar
kdock
5StarLounger
Posts: 638
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.
"The most convincing argument against time travel is the remarkable scarcity of time travelers." Arthur C. Clarke

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

Re: Case sensitive style names

Post by HansV »

:laugh:
Regards,
Hans