Reputation: 200
Could you please provide code for converting the following VB code using MS Word to VB.NET using Aspose Word?
Dim os AS Excel.Worksheet
oS.Range("A55", "S55").Select()
oS.Application.Selection.Copy()
oS.Application.Selection.Insert(Shift:=Excel.XlDirection.xlDown)
thans all and Best wishies.
Upvotes: 0
Views: 209
Reputation: 458
It seems you are interested in a code for Aspose.Cells API rather than Aspose.Words API as you are manipulating Excel files.
Well, as per your shared code, you are getting a range of cells, copying the cells at the same selected location with "Shift Cells Down" option. You can transform this to Aspose.Cells code as below:
'Open the Source Excel file
Dim workbook As New Workbook("C:\Test_File.xlsx")
'get cells collection of first worksheet
Dim cells As Cells = workbook.Worksheets(0).Cells
'get the source range to copy
Dim sourceRange As Range = cells.CreateRange("A55:S55")
'Insert the range below the source range
Dim ca As CellArea = CellArea.CreateCellArea("A56", "S56")
cells.InsertRange(ca, ShiftType.Down)
' Move Source Range one Row down as Copy process has Shift Cells Down option selected
' this is only required if you have a named range and want it shifted as in Excel
sourceRange.MoveTo(55, 0)
'create destination range
Dim destinationRange As Range = cells.CreateRange("A55:S55")
'Copy the source range data to desitnation range (newly inserted range)
destinationRange.Copy(sourceRange)
'save the resultant file
workbook.Save("C:\Test_Out.xlsx")
Hopefully, the above code will help you in your implementation.
Upvotes: 1