Results 1 to 9 of 9

Thread: VBA code that changes the font size of spaces but only applied to selected text

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Quote Originally Posted by gmaxey View Post
    Sub ReduceSpaces()
    Dim oRng As Range
      Application.ScreenUpdating = False
      Set oRng = Selection.Range
      With oRng.Find
        .ClearFormatting
        .Text = "^w"
        .Replacement.ClearFormatting
        .Replacement.Font.Size = oRng.Font.Size - 0.5
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .Execute Replace:=wdReplaceAll
      End With
      Application.ScreenUpdating = True
    lbl_Exit:
      Exit Sub
    End Sub
    You know, I was already considering trying to find a method to contact you after seeing your site, but I thought you'd already have retired from helping people or something.

    Goddamn thank you so much! This is a big step forward in the right direction. The only thing I did from here on, to be able to go from 9pt to 8pt and so forth, is creating separate macros where the 'original font size' is reduced with '1pt', '1.5pt' and '2pt'.

    It does seem to work that way, but the only thing I can't figure out is how to assign a keyboard shortcut (e.g. ctrl+7) to a macro. Because the way I do it now, is to create a faux macro, assign a key to it, and then paste your code into it. But once I do that, the shortcut combination doesn't work anymore. Any suggestions?

    Also: is there a way the code can detect the font size of the spacing and reduce that by 0.5? Then I only need one macro
    Last edited by ResidenCV; 06-09-2023 at 11:42 AM.

Posting Permissions

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