We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Highlight selected rows and delete it


Is there a way at to highlight the number of rows and do a delete all those rows? Currently this is how it's done in the Word Object.

WordObj.Selection.MoveDown(Unit:=wdParagraph, Count:=3)
WordObj.Selection.MoveRight(Unit:=wdCell, Count:=1)
WordObj.Selection.MoveDown(Unit:=wdParagraph, Count:=8, Extend:=wdExtend)

Also, since there is no MoveUp/MoveDown in Aspose.Words how could the following be done?

WordObj.Selection.MoveUp(Unit:=wdLine, Count:=2)
WordObj.Selection.MoveDown(Unit:=wdLine, Count:=2)

Do I just have to define the exact row to clone? Any advice/suggestions or even better code sample would be great. Thanks for your help. By the way, I'm using VB .NET.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. You can remove table rows using the following code:

'Get table

Dim tab as Table = doc.FirstSection.Body.Tables(0))

'Remove row from table


You should clone existing row and use InsertAfter method for inserting this row after original row.

'Open document

Dim doc As Document = New Document("test.doc")

'Get table from the second section of document

Dim myTable As Table = doc.Sections(0).Body.Tables(0)

'Get row of table (its idex is 16)

Dim myRow As Row = myTable.Rows(16)

'Clone row

Dim newRow As Row = CType(myRow.Clone(True), Row)

myTable.InsertAfter(newRow, myRow refRow)

'Save document


Hope this helps.

Best regards.

Thanks for your help!