last day (19 days later) » 

5:44 PM
2
A: Changing the formatting of white-space to match the adjacent formatting, intelligently?

robinCTS Word's "wildcard" find and replace uses a (very) limited, non-standard form of regular expressions. Coupled with the fact that you want to find and replace formats as well, means that it is not possible to do what you require purely using the built-in find and replace, wildcards or not. Howeve...

 
This looks very promising. I will certainly test it out. Do you have a link to a video tutorial that will teach me how to install and run this macro (perhaps with it bound to a hotkey).
 
@AlexanderDixon Hmm. I neither do, nor watch (mostly ;-) ) video tutorials. I'll see if a can track one down for you. I do have a link to a Microsoft article with a lot of pretty pictures :-) It shows how to write macros and bind them to a hotkey. Installing a macro is exactly the same. Just copy/paste the code from the answer into the module.The article is for Word 2010, but the process is the same for all versions. (Although the "Customize Keyboard" dialog to set the hotkey is in different places.)
 
This worked perfectly. I appreciate your time, dedication and above and beyond help with this. One minor request, is that for the last sentences where the last punctuation character happened to be formatted, when it should not have been, it gets included in the html wrapping. This is minor niche/nuanced case but I figured I'd mention it in case you knew how to get around it. So when I tested everything worked but I got ?</em> in one case, which obeys the criteria, but it should be </em>? just because...
 
@AlexanderDixon Thanks. Not much luck with finding a video tutorial, though. Found this, the first two minutes of which show how to open up the VBA editor and type in a macro. Looks like you managed without, though ;-) As far as the punctuation request goes, that should be a trivial modification. Just need a bit more info. 1) When do you wish to exclude trailing punctuation? Always? 2) What precisely constitutes punctuation? ?!.,:;-?
 
yes to both of your questions.
 
5:44 PM
@AlexanderDixon OK. Answer has been updated with the new version. Punctuation is now treated just like white-space. That also means that unformatted punctuation in the middle of formatted text will also be correctly formatted.
 
I'm running into a case where this macro cannot run due to a 4608 runtime error: value out of range. It seems to be choking on the underline code specifically at If NotJustWhiteSpaceOrPunctuation(rngFound.Parent.Range(rngExpa‌​nded.End, rngFound.Start)) Then Exit Do Do you have an email account where I could send the document to you so you can see exactly what is going on?
 
@AlexanderDixon Sure. Use nospaamm-AlexanderDixon@yahoo.com - I saw that error a few times when debugging. Thought I'd taken care of all the edge cases.
 
Hi robinCTS, that email did not work
@robinCTS Hello,

Attached please find a real case document where I attempted to apply the script that you so kindly provided me with yesterday.  I sunk a bit of time trying to figure out what outlier was casing the bug.  I found that it is because question 9 (towards the bottom) has a table element.  I do not know how VBA Script traverses table elements, but ideally, it should ignore the table element as a whole, but,  rather, traverse into each cell and do the necessary replacements within each cell.
 
I just created the that email address. Should have worked straight away. Try nospaamm-github@yahoo.com instead. I know that one definitely works.
 
6:03 PM
Okay, I sent it to nospaamm-github@yahoo.com and did not get any errors.
 
Yep, got it. The only thing I can think of with nospaamm-AlexanderDixon@yahoo.com is that maybe Yahoo doesn't like capital letters as none of my other disposable addresses have them and they all work. (And yet Yahoo allowed me to create it.) Will do some testing later on.
 
Awesome, thanks.
 
6:24 PM
Oh, BTW, I've suggested an edit to you question. If you think it's OK could you approve it?
 
Ta.
 
 
2 hours later…
8:20 PM
Hi, I know it's 4 o'clock on a Friday, but were you able to fix those minor issues today? No rush or anything because it still works great if I take out the table.
 

  last day (19 days later) »