Hi, I'm hoping for help to write a macro sort of like "Convert Text to Title Case (Smart)" but with 2 changes:
1) expands the list of words to not capitalize to include:
a, an, and, as, at, between, but, by, down, for, from, in, into, nor, of, on, or, over, the, to, under, up, yet
2) if a colon appears (:), it is followed by one space (rather than none or more than one) and then the next word is always capitalized (i.e. even the words in the above list are capitalized)
So the string "Go Over the mountain:a journey" would become "Go over the Mountain: A Journey".
Can anyone help? Thanks!
Patrick here whipped up an update to the script that should do what you're looking for. I've attached it to this reply so you can download it an import it :)
Hope that helps!
Wow, many thanks! You even nicely commented the code so I can tinker with it without learning to program.
One more request: can you do a version that will work on selected text without me having to copy it? So text that is currently selected can be corrected with one hotkey? Or, is there a way for me to do that in the program in some other way?
OK, I know I'm being a pain now, but due to a different citation system, I now also need a macro that will convert a string of text to all lower case *except* for the following, which should be uppercase:
- the first letter in the string
- the first letter after a colon
- the words "England" and "America" (I have other proper nouns also, but if you just put in these two I'm sure I can figure out how to add others)
And, as before, colons should be followed by exactly one space.
And, as stated just above, I'd like the macro to copy selected text, fix capitalization, and then paste the fixed text automatically so that I can perform this operation by selecting the text and pressing one hotkey.
I'm hoping that if you provide this, I'll be able to make any further variations on my own!
I really, really, appreciate it!
I've attached an update to the first one that auto-copies/pastes. Also attached a second one with your other requests.
Hope that helps!
Many thanks! But I am having problems.
With "Convert Text to Almost Lower Case",
"THIS IS MY TEST STRING:ENGLAND" becomes "THIS is my test string: ENGLAND". I'm hoping for "This is my test string: England"
And with both of the macros, when I select some words and run the macro, the macro operates on whatever was already in the clipboard--it doesn't first copy the selected words.
--Edit--
Looking at the code, there's a line commented "// Leave words after colons alone". But what you might want to do is lowercase everything, capitalize the first letter of the whole string, capitalize the first letter following the colon, and then capitalize any words on the "proper nouns" list. That way it can deal with all-lowercase and all-uppercase input in the same way.
Dec 19, 2018 (modified Dec 19, 2018)
•
#6
Try this one out :)
When I test by highlighting text in Notepad and running the macro, it replaces the text correctly. Are you running the macro with a hotkey or from the macros menu?
I was actually testing in the Macro settings window with 'Run Function', but I now realize that was a bad idea. This one works!
Two follow-up questions:
1) As mentioned, I'm not a programmer, but is there any way to use wildcards or regular expressions in the code to more easily indicate words not to capitalize? I'm thinking something like "America*" for America, American, Americas, Americans, etc.
2) If I end up with a list of words to always capitalize that is 2000 words long, is that going to impact performance substantially?
Try this one out, it will now leave a word capitalized if it it contains a word on the ignore list (e.g. Americans contains America, so it will remain capitalized).
It may be a bit slower if you have thousands of words in the ignore list, but I can't imagine it would take more than a handful of seconds to run still.
I tried this with an all-lowercase "american" and it didn't capitalize it. Does it work for you?
OK, it's working now. I figured out how to add spaces after ? and ! using the colon code, but I also need to remove any "." or " " (period or space) if it is the last character in the string. Can you tell me how to trim it? Thanks for the great customer service!
No worries! We've been swamped this week due to the holidays, but I will hopefully get a chance to look at this next week for you.
It worked! But when I tried to add the same function to "Convert Text to Title Case (Smart with Colons)" I got a compile error. Any idea why?
I'm back with 2 more improvement requests.
First, can this be modified to ignore any leading non-alphabetic characters and capitalize the first alphabetic character? So running it on:
5. this is the title
or
- my first bullet point
would produce
5. This is the title
and
- My first bullet point
Second, can this be modified to treat every line as a separate instance to be capitalized? So I could highlight the entirety of:
- title one
- title two
- title three
And in one keystroke get:
- Title one
- Title two
- Title three
Thanks!
It should be possible, I will have a look at it when I get a chance. It might not be until next week though.
Thanks again! I have it basically working and even modified it to deal with question marks etc. in addition to just the colon. One problem is that after running the macro on text, it leaves the cursor on the next line after the text. Can this be corrected so it remains at the end of the bottom pasted line?
I am also having a problem with one other modification. I want it to capitalize words following a hyphen and a space - "- " but not after hyphens that are not followed by space - "north-east". I tried this in line 97 of the attached macro but it isn't working. Is it possible to do what I want?
edit: also, it doesn't capitalize correctly after a numeral not followed by a period. So it does turn "5. test" into "5. Test", but it doesn't turn "5 test" into "5 Test". Can this be corrected?
I'm sorry if I'm asking for too much support on this macro--let me know. It has been very helpful for me!
• Attachment [protected]: frank99macro.macro [6,539 bytes]
Mar 15, 2019 (modified Mar 18, 2019)
•
#20
Hi, it's been a month, so just wanted to bump this thread in case it was forgotten.
Also, one other question. In the list of words to capitalize, I'm finding that two-word phrases like "Hong Kong" are not being capitalized. Is it because they are two words, or is there some other explanation? Is there any way to capitalize two-word phrases?
Ok, I've completely re-written this macro, hopefully it's what you're looking for. If not, please let me know. Small tweaks should be much easier now.
Thanks!
Great work! Just one question about modifying it. It currently reads:
// Capitalize words after colons or hyphens
if (words[i - 1].EndsWith(":", StringComparison.OrdinalIgnoreCase) ||
words[i - 1].EndsWith("-", StringComparison.OrdinalIgnoreCase)
What do I add if I want to also capitalize words after questions marks or other punctuation? I tried to fix it myself but it didn't work.
The macro is generally working but is producing a mistake I can't explain. For the text string, "The Psychological Functions of Justice in Mass Media", when I run the macro, I get "The psychological functions of Justice in mass media" with the word "Justice" capitalized. It should not be capitalized. I that word is not in the list of exceptions. Can you explain? I've attached my version with a longer list of exceptions than the one you sent me. Thanks!
Edit: another example: "Universal Morality, Mediated Narratives, and Neural Synchrony" becomes "Universal morality, mediated narratives, and Neural synchrony" - "Neural" is mistakenly capitalized. But "A Model of Intuitive Morality and Exemplars" correctly becomes "A model of intuitive morality and exemplars". So weird.
• Attachment [protected]: Uppercase for Citations (user modify).cfmacro [41,600 bytes]
Jul 26, 2019 (modified Jul 26, 2019)
•
#26
Weird! When I run my original version, "justice" doesn't get capitalized, but when I run yours, it does. I'll have a look at this and see what I can find out.
Ok, could you try this one out and let me know how it goes? I also fixed a bug where it wouldn't capitalize exception words if they had a space in them.
Thanks for the macro. When I run the macro on "The Psychological Functions of Justice in Mass Media" I get "The psychological functions of jUStice in mass media", presumably because "US" is in the exceptions list. I suppose if you are going to re-capitalize the exceptions items, you will need to check that they are stand-alone words.
BTW, would you mind removing my personal name from the macro name you attached? I tried to change it in the one I attached but I guess it was in the code somehow. Thanks!
Jul 27, 2019 (modified Jul 27, 2019)
•
#29
Hi, 117 doesn't look like that. I've attached my version. But now it changes "The Psychological Functions of Justice in Mass Media" into "The psychological functions of Justice in mass media", which is better but still not what I'm trying to get. Your help is very appreciated!
• Attachment [protected]: Uppercase for Citations (user modify).cfmacro [41,592 bytes]
Just following up on the last message. I just got another example: it changes "Seeing Ourselves Through Technology: How We Use Selfies, Blogs and Wearable Devices to See and Shape Ourselves" into "Seeing ourselves through technology: How we Use selfies, blogs and wearable devices to see and shape ourselves"
No idea why the "Use" is capitalized in the 2nd case.
I have again attached my script. Thanks.
• Attachment [protected]: Uppercase for Citations (user modify).cfmacro [42,200 bytes]
Sorry for the delay on this. Could you try this updated version?
It works! If it's easy to explain, I'd love to know what you did that fixed it.
That worked! I've now realized that the change to Title Case macro you made for me has two problems. First, it incorrectly capitalizes the final "s" in titles with possessives, so "the critic´s share" becomes "The Critic´S Share". Also, I tried to modify it to change smart apostrophes to dumb ones, but it's not working. I've attached the macro. Can you suggest a fix?
• Attachment [protected]: Convert Text to Title Case (user modify) 2019-11-05.cfmacro [1,336 bytes]
I don't think the export worked. I tried importing it but it's just a blank Macro. Could you try again?
OK!
• Attachment [protected]: Convert Text to Title Case (user modify) 2019-11-07.cfmacro [15,984 bytes]