Hello all,
I appologize for the basic nature of this question but didn't turn up much that I understoop in search of the board or VBA Help.
Task at hand: automatically print set of cash receipts with serial numbers, given number of copies to print; save and close worksheet.
Sheet1 consists of 4 cash receipts (2 printable pages) with serial numbers - say 001 through 004. Macro should get next serial number (005 - calulated in a cell named New_Serial_No) and put it in a cell named First_Serial_No; calculate and print; repeat until completing a given number of copies (value entered in cell named Number_To_Print); save and close.
Here is code - crashes when executed with error "Object doesn't support this property or method".
===================
Dim Counter As Integer
Dim Number_To_Print As Integer
Dim New_Serial_No As Integer
Dim MyCell As Range
Private Sub PrintLoop()
MyCell = ActiveSheet.ActiveCell
Number_To_Print = Range("Sheet1!Number_To_Print").Value
Counter = 0
Do
With Worksheets("Sheet1")
New_Serial_No = .Range("New_Serial_No").Value
.Range("First_Serial_No") = New_Serial_No
.Calculate
.Print
Counter = Counter + 1
End With
Loop While Counter < Number_To_Print
Range(MyCell).Select
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
===============
Any suggestions/corrections much appreciated.
Regards,
alriemer
I appologize for the basic nature of this question but didn't turn up much that I understoop in search of the board or VBA Help.
Task at hand: automatically print set of cash receipts with serial numbers, given number of copies to print; save and close worksheet.
Sheet1 consists of 4 cash receipts (2 printable pages) with serial numbers - say 001 through 004. Macro should get next serial number (005 - calulated in a cell named New_Serial_No) and put it in a cell named First_Serial_No; calculate and print; repeat until completing a given number of copies (value entered in cell named Number_To_Print); save and close.
Here is code - crashes when executed with error "Object doesn't support this property or method".
===================
Dim Counter As Integer
Dim Number_To_Print As Integer
Dim New_Serial_No As Integer
Dim MyCell As Range
Private Sub PrintLoop()
MyCell = ActiveSheet.ActiveCell
Number_To_Print = Range("Sheet1!Number_To_Print").Value
Counter = 0
Do
With Worksheets("Sheet1")
New_Serial_No = .Range("New_Serial_No").Value
.Range("First_Serial_No") = New_Serial_No
.Calculate
Counter = Counter + 1
End With
Loop While Counter < Number_To_Print
Range(MyCell).Select
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
===============
Any suggestions/corrections much appreciated.
Regards,
alriemer