View Single Post
 
Old 04-21-2012, 07:43 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Word VBA: Cannot Edit Range (Delete characters except the first in a table cell)

CannotEditRange.zip

Code:
Sub t()
''' Retain every first character of each cell in Table 1


Dim oRange As Range

With Selection
    Set oRange = .Range
    With oRange
        .Start = .Start - 1
        .Delete ''' Run-time error 5904: Cannot edit Range
    End With
End With

End Sub
There's a table with 3 cells / rows.
Each row has a string like "abcde".
I want to delete all the characters except the first one.
I don't know why my codes above only show errors when the strings are inside a table cell. (If "abcde" is in a paragraph, it works)
Reply With Quote