# Revision history [back]

Well, I went back to use the copyRange method, and somehow was able to get it to work this time - at least to resolve problem 1. Here is the code I have now:

Dim shtSource As Object
Dim rngPrintArea As Object
Dim shtReceipt As Object
Dim rngDest As Object
Dim i As Integer

shtSource = oDoc.Sheets.getByName(sTransType)
rngPrintArea = shtSource.getCellRangeByName(sTransType & "PrintArea")
shtReceipt = oDoc.Sheets.getByName("Receipt")
shtReceipt.Unprotect("")

rngDest = shtReceipt.getCellRangeByName("ReceiptOne")
rngDest.CellBackColor = RGB(255,255,255)
rngDest.ClearContents(128)  ' get rid of any buttons copied

rngDest = shtReceipt.getCellRangeByName("ReceiptTwo")
rngDest.CellBackColor = RGB(255,255,255)
rngDest.ClearContents(128)  ' get rid of any buttons copied

' Make sure the columns are the right width
' Since receipts are stacked, changing one changes both
For i = 0 to rngPrintArea.Columns.getCount-1
rngDest.Columns.getByIndex(i).Width = rngPrintArea.Columns.getByIndex(i).Width
Next i
shtReceipt.Protect("")

Dim view As Object
view = oDoc.getCurrentController()
view.setActiveSheet(shtReceipt)
oDoc.Print(Array())
view.setActiveSheet(shtSource)


When I had tested copyRange before, I don't remember building up oDestCell like that, so maybe that was my problem. Anyway, this code seems to work for copying the range over to the receipt sheet. I still can't get the print to print the right sheet, but since that's a different problem, I think I will post it as a separate question, so it doesn't get lost.