This works for me
var range = doc.Range();
range.Start = doc.GoTo(WdGoToItem.wdGoToPage, WdGoToDirection.wdGoToAbsolute, pageStart).Start;
if (pageend < doc.ComputeStatistics(WdStatistic.wdStatisticPages, false))
{
range.End = doc.GoTo(WdGoToItem.wdGoToPage, WdGoToDirection.wdGoToAbsolute, pageend + 1).End - 1;
}
range.Copy();
The new range select the entire document, so its End is already the document's end. The start is set according to the start of the start page you need. The end is set as the beginning of page (pageend + 1), minus 1 character (to get back). This will bring us to the end of page pageend. This is only done if pageend is not the last page.
We could fit it all inside the range initialization, but that will make the code unreadable.