Consulting

Results 1 to 3 of 3

Thread: Custom AutoFormatAsYouType

  1. #1
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    298
    Location

    Custom AutoFormatAsYouType

    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

  2. #2
    VBAX Regular
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    90
    Location
    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.

  3. #3
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    298
    Location
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •