How Can i Find out the Selected Text in excel Textframe? RRS feed

  • Question

  • I am working on a plugin where i have to find out the selected text in excel textframe but unable to find any method related to selected text whereas in word and powerpoint there is way like Application.Selection.text to get the selected text but i am not able to find out anything like this in excel.
    Wednesday, September 4, 2019 5:53 AM

All replies

  • Hi,

    This is a VBA sample in Excel.

    Private Sub btn_Find_Shapes_Click()
        Range("A11:B50").Value = ""
        Dim myRow As Integer: myRow = 11
        Dim shp As Shape
        For Each shp In ActiveSheet.Shapes    ' -- get all shapes (including TextBox) in a sheet
            If (shp.Type = msoTextBox) Then   ' -- check if it is a TextBox 
                Cells(myRow, 1).Value = shp.Name
                Cells(myRow, 2).Value = shp.TextFrame.Characters.Text   ' -- text in TextBox
                myRow = myRow + 1
            End If
    End Sub
    I hope this will give you a hint.


    Ashidacchi --

    • Proposed as answer by Scott Gall Saturday, September 14, 2019 8:47 PM
    Wednesday, September 4, 2019 10:27 AM