Log in

View Full Version : [SOLVED:] Custom AutoFormatAsYouType



lynnnow
12-09-2022, 08:55 AM
Hi,

I have a find and replace macro that looks for specific symbols to format sentences as italics, bold, bold+italics, etc. This macro is executed from a button. I'm trying to upgrade the functionality to an AutoFormatAsYouType kind of function but with my custom symbols as it is used to create an HTML table with the specified formatting.

Here is a sample for the italics formatting.

Options.DefaultHighlightColorIndex = wdBrightGreen
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Highlight = True
With .Replacement.Font
.Bold = False
.Italic = True
End With
.Text = "^^*|"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.MatchWildcards = True
End With


The Convert to HTML function uses a sequence of Replace functions looking for these custom symbols. Any help in pointing me in the right direction would help.

Thanks in advance.

Lynnnow

Chas Kenyon
12-09-2022, 05:55 PM
Beyond my limited abilities, but I am certain that doing something like this as AutoFormat As You Type is going to be painfully intrusive and slow Word down. Consider, instead of vba, using straight AutoCorrect.

lynnnow
12-09-2022, 10:10 PM
I'm not sure if AutoCorrect accepts asterisks as wildcards for replacing formatting. The length of the string between the symbols can vary from a few characters to even over a hundred characters, so only if AutoCorrect can identify the full string of characters between the symbols will it work. But, yes, I knew it was going to be a bit unreasonable developing something like this. I was thinking of using a hybrid technique with using asterisks and underscores to achieve the same result, will delve into looking in that direction since it is already available in Word.

Mira23
10-15-2023, 08:18 PM
I'm not sure if AutoCorrect accepts asterisks as wildcards for replacing formatting. The length of the string between the symbols can vary from a few characters to even over a hundred characters, so only if AutoCorrect can identify the full string of characters between the symbols will it work. But, yes, I knew it was going to be a bit unreasonable developing something like this. I was thinking of using a hybrid technique with using asterisks and underscores to achieve the same result, will delve into looking in that direction since it is already available in Word.
Have you tried using this method yet? Is it dino game (https://dino-game.org) effective?

lynnnow
10-15-2023, 11:14 PM
Have you tried using this method yet? Is it dino game effective?

Hi Mira,

Unfortunately it is not for dino game (not even sure if you're referring to the Google dino game, sorry). I have quit looking for a solution for this query, however.

Aussiebear
10-16-2023, 01:27 AM
Mira23 was simply trying to spread spam, so has left the building.