In order to get a valid collection of selected cells, when there's contiguous selection in table. This solution is by no means perfect but it delivers and I didn't managed to think of something better. I managed to find a solution thanks to article posted by Tim Williams. My question's, how I can obtain valid selected cells collection when user selects area in Word table which is not rectangle? Tekst2 = tekst2 & vbCrLf & "Cells count: " & CStr(liczbaKomorek2) Tekst1 = tekst1 & vbCrLf & "Cells count: " & CStr(liczbaKomorek1) Tekst2 = tekst2 & "#Cell: " & CStr(indekser2) & " Value: " & CStr() & " Column: " & CStr(komorka.ColumnIndex) & " Row: " & CStr(komorka.RowIndex) & vbCrLf Tekst1 = tekst1 & "#Cell: " & CStr(indekser1) & " Value: " & CStr() & " Column: " & CStr(komorka.ColumnIndex) & " Row: " & CStr(komorka.RowIndex) & vbCrLfįor Each komorka In .Selection.Cells Tekst2 = "Lista komorek 2 (): " & vbCrLf & vbCrLf & vbCrLfįor Each komorka In Tekst1 = "Lista komorek 1 (): " & vbCrLf & vbCrLf & vbCrLf
#Microft word selection is locked code#
This is vba code I'm using for testing purpose, when there's cells range selected in Word table: Sub test() Range.Cellsīoth of those properties returns different and invalid selected cells collection when user selects non rectangle table cells area. I've created a simple vba code for testing what cells are selected in table using two properties: .Cells If users selects area which is not rectangle or selects more than one area (while holding CTRL down), this property returns invalid collections of cells. This's how I'm getting selected table cells in my Word Addin: .Cells Everything works fine when user selects rectangle area of cells. I need collection of selected table cells to create custom bookmark object with information what cell range has been selected by the user. I'm trying to get selected cells from Word table.