2016-06-16 1 views
1

나는 vba를 통해 인쇄하고 싶은 2 페이지짜리 시트를 가지고 있습니다. 여기에 vba가해야 할 일이 있습니다 :
- 첫 페이지를 "A1 : P38"으로 정확히 인쇄하십시오.
- 두 번째 페이지 "A39 : P82"를 첫 번째 페이지와 함께 연속으로 인쇄하십시오. 인쇄 명령을 한 줄로 써야합니까?). 정확한 범위를 인쇄하는 경우 앞면과 뒷면 페이지 선이 일치해야합니다.vba를 통해 인쇄

현재 "A1 : P82"범위를 인쇄하려고하면 첫 페이지에 "A1 : P37"이 인쇄되고 두 번째 페이지에는 나머지가 인쇄됩니다. 동료가 인쇄를 시도하면 첫 페이지에는 "A1 : P39"가 인쇄되고 두 번째 페이지에는 나머지가 인쇄됩니다. 어떤 아이디어? 인쇄 할 시트를 첨부했습니다. 인쇄를 시도하면 첫 번째 페이지가 한 줄 아래로 인쇄되고 친구가 인쇄를 시도하면 첫 번째 페이지에 한 줄 더 인쇄합니다. 두 경우 모두 페이지 일치가 취소됩니다. 첫 번째 페이지는 P38 행까지만 인쇄해야합니다.
아래에 내 코드가 첨부되어 있습니다. 미리보기를 표시할지 아니면 직접 인쇄 할지를 선택하는 두 가지 확인란, 사용자가 알림 메시지를 보려고하는지 여부를 선택하는 두 가지 확인란이 있습니다.
enter image description here

코드 :

Private Sub CommandButton1_Click() 
Dim rowLast As Integer 
Dim pages As Integer 
Dim i As Integer 
Dim bins As Integer 
Dim count As Integer 

rowLast = Sheets("Kanban Print").Cells(Rows.count, "A").End(xlUp).Row 
bins = Sheets("RecManip").Cells(4, "B").Value 
If rowLast = 1 And CheckBox1.Value = True Then 
    MsgBox "Common error: Nothing to print." 
End If 
pages = Application.WorksheetFunction.RoundUp((rowLast - 1) * (bins/2), 0) 

For i = 1 To pages 
    Sheets("RecManip").Cells(1, "B").Value = i 
    If CheckBox3.Value = True Then 
     Range("A1:P82").PrintOut preview:=True 
    Else 
     Range("A1:P82").PrintOut 
    End If 
Next 

If rowLast > 1 And CheckBox1.Value = True Then 
    MsgBox (rowLast - 1) & " cards printed for " & bins & " bin system." 
End If 

Sheets("RecManip").Cells(1, "B").Value = 1 
Range("A1").Select 

End Sub 

감사합니다. Gserg에

enter image description here

+0

현재 접근 ... – Verzweifler

+0

@Verzweifler 편집을 알려주십시오. –

+1

[실제 페이지 나누기] (https://support.office.com/en-us/article/Insert-move-or-delete-page-breaks-in-a-worksheet-ad3dc726-beec-4a4c-861f- ed640612bdc2) 'From : = 1, To : = 1' 및'From : = 2, To : = 2'를 인쇄 하시겠습니까? – GSerg

답변

0

감사 :

Private Sub CommandButton1_Click() 
Dim rowLast As Integer 
Dim pages As Integer 
Dim i As Integer 
Dim bins As Integer 
Dim count As Integer 

rowLast = Sheets("Kanban Print").Cells(Rows.count, "A").End(xlUp).Row 
bins = Sheets("RecManip").Cells(4, "B").Value 
If rowLast = 1 And CheckBox1.Value = True Then 
    MsgBox "Common error: Nothing to print." 
End If 
pages = Application.WorksheetFunction.RoundUp((rowLast - 1) * (bins/2), 0) 

For i = 1 To pages 
    Sheets("RecManip").Cells(1, "B").Value = i 
    If CheckBox3.Value = True Then 
     Range("A1:P82").PrintOut preview:=True 
    Else 
     Sheets("Kanban Card template").PrintOut From:=1, To:=2 
    End If 
Next 

If rowLast > 1 And CheckBox1.Value = True Then 
    MsgBox (rowLast - 1) & " cards printed for " & bins & " bin system." 
End If 

Sheets("RecManip").Cells(1, "B").Value = 1 
Range("A1").Select 

End Sub 
관련 문제