Consulting

Results 1 to 2 of 2

Thread: Apply style to selected text not selected box

  1. #1
    VBAX Regular
    Joined
    Apr 2015
    Posts
    27
    Location

    Apply style to selected text not selected box

    Hi guys!
    this is going to be easy for any VBA expert out there so, apologies for the novice question! I have a code to condense text into a text box. At the moment the code condensed all the text inside the text box but I want the code to work for selected text only. How can I modify this code to make it work?

    Many thanks on advance!
    PJ

    Sub CondenseText()
    
    
        On Error GoTo Catch
    
    
        Dim o As Shape, b As Boolean
        Set o = ActiveWindow.Selection.ShapeRange(1)
        If Not o Is Nothing Then
            With o
                .TextFrame2.TextRange.Font.Spacing = .TextFrame2.TextRange.Font.Spacing - 0.1
            End With
        End If
        Exit Sub
    Catch:
        If Err.Number = -2147188160 Then MsgBox CG_NOTHING_SELECTED
    End Sub

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Sub CondenseText()
        On Error GoTo Catch
        Dim o As TextRange2, b As Boolean
        Set o = ActiveWindow.Selection.TextRange2
        If Not o Is Nothing Then
            With o
                .Font.Spacing = .Font.Spacing - 0.1
            End With
        End If
        Exit Sub
    Catch:
        If Err.Number = -2147188160 Then MsgBox "NOTHING_SELECTED"
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Tags for this Thread

Posting Permissions

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