Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Printing problem

I have this small macro, that after printing 3pages, just give an error,
I guess it need some time of pause between every page, but I don't know
much about this language, (VBA) can someone help me?

Thanks,

Fernando

CODE

Private Sub CommandButton1_Click()
ans = MsgBox("Do you want to print faxes?", vbYesNo)
If ans = vbNo Then
Exit Sub
End If
Dim col As Integer
Dim row As Integer
Dim counter As Integer
Dim I As Integer


col = 2
row = 2
counter = 1

For row = row To 20
If Sheet8.Cells(row, counter) = "" Then
Exit Sub
Else
Sheet1.Cells(3, 7) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 3) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 6) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 9) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 12) = Sheet8.Cells(row, counter)
counter = counter + 1
counter = 1
Sheet1.PrintOut
Sheet8.Cells(row, 5) = "PRINTED"



For I = I To 300
Next I
I = 0


End If
Next row

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Printing problem

I'd stay away from variables like Row. It looks way to much like the VBA
property .Row. It may not confuse excel, but it would confuse me.

And I think I'd use something more like this:

Option Explicit
Private Sub CommandButton1_Click()

Dim Ans As Long
Dim myRow As Long

Ans = MsgBox("Do you want to print faxes?", vbYesNo)
If Ans = vbNo Then
Exit Sub
End If

For myRow = 2 To 20
If Sheet8.Cells(myRow, 1) = "" Then
Exit Sub
Else
Sheet1.Cells(3, 7).Value = Sheet8.Cells(myRow, "A").Value
Sheet1.Cells(5, 3).Value = Sheet8.Cells(myRow, "B").Value
Sheet1.Cells(5, 6).Value = Sheet8.Cells(myRow, "C").Value
Sheet1.Cells(5, 9).Value = Sheet8.Cells(myRow, "D").Value
Sheet1.Cells(5, 12).Value = Sheet8.Cells(myRow, "E").Value
Sheet1.PrintOut preview:=True
Sheet8.Cells(myRow, 5) = "PRINTED"
End If
Next myRow

End Sub


(Preview:=true is to save paper while testing.)

But your loop
for row = row to 20
looks like a typo

And instead of using a counter, I just plopped the actual column letter into the
assignment lines.

Fernando Duran wrote:

I have this small macro, that after printing 3pages, just give an error,
I guess it need some time of pause between every page, but I don't know
much about this language, (VBA) can someone help me?

Thanks,

Fernando

CODE

Private Sub CommandButton1_Click()
ans = MsgBox("Do you want to print faxes?", vbYesNo)
If ans = vbNo Then
Exit Sub
End If
Dim col As Integer
Dim row As Integer
Dim counter As Integer
Dim I As Integer

col = 2
row = 2
counter = 1

For row = row To 20
If Sheet8.Cells(row, counter) = "" Then
Exit Sub
Else
Sheet1.Cells(3, 7) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 3) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 6) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 9) = Sheet8.Cells(row, counter)
counter = counter + 1
Sheet1.Cells(5, 12) = Sheet8.Cells(row, counter)
counter = counter + 1
counter = 1
Sheet1.PrintOut
Sheet8.Cells(row, 5) = "PRINTED"

For I = I To 300
Next I
I = 0

End If
Next row

End Sub


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 printing problem--printing 1 document on 2 pages Bons Excel Discussion (Misc queries) 0 December 24th 09 04:15 PM
Printing problem vrftb New Users to Excel 0 October 19th 08 01:22 AM
Printing problem Dr Fumanchu Excel Discussion (Misc queries) 1 February 27th 08 01:54 PM
Printing Problem Mamaschantz Charts and Charting in Excel 1 September 11th 07 04:33 PM
Printing problem Dudley Excel Discussion (Misc queries) 2 December 20th 05 04:37 PM


All times are GMT +1. The time now is 01:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"