PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : پرینت از چک باکس مورد نظر



ali719
2015/05/17, 21:32
سلام
در فایل پیوست من میخوام با انتخاب چک باکس و زدن روی دکمه پرینت از شیت مورد نظر آن شیت پرینت گرفته شود (مثلا چک باکس 1و4 را انتخاب و با زدن روی دکمه شیت های مورد نظر آن شیت پرینت گرفته شود) و با زدن روی دکمه پرینت از کل شیتها تمام شیتها پرینت گرفته شود.برای این منظور برای دکمه ها چه فرمولی بنویسم.
با تشکر

generalsamad
2015/05/17, 21:55
با سلام
از این کد استفاده کنید
ببینید خواستتون همین بوده


Option Explicit
Private Sub CommandButton1_Click()
Dim i As Integer
Dim TopPos As Integer
Dim SheetCount As Integer
Dim PrintDlg As DialogSheet
Dim CurrentSheet As Worksheet
Dim cb As CheckBox
Application.ScreenUpdating = False

If ActiveWorkbook.ProtectStructure Then
MsgBox "Workbook is protected.", vbCritical
Exit Sub
End If

Set CurrentSheet = ActiveSheet
Set PrintDlg = ActiveWorkbook.DialogSheets.Add

SheetCount = 0

TopPos = 40
For i = 1 To ActiveWorkbook.Worksheets.Count
Set CurrentSheet = ActiveWorkbook.Worksheets(i)

If Application.CountA(CurrentSheet.Cells) <> 0 And _
CurrentSheet.Visible Then
SheetCount = SheetCount + 1
PrintDlg.CheckBoxes.Add 78, TopPos, 150, 16.5
PrintDlg.CheckBoxes(SheetCount).Text = _
CurrentSheet.Name
TopPos = TopPos + 13
End If
Next i

PrintDlg.Buttons.Left = 240

With PrintDlg.DialogFrame
.Height = Application.Max _
(68, PrintDlg.DialogFrame.Top + TopPos - 34)
.Width = 230
.Caption = "Select sheets to print"

End With

PrintDlg.Buttons("Button 2").BringToFront
PrintDlg.Buttons("Button 3").BringToFront

CurrentSheet.Activate
Application.ScreenUpdating = True
If SheetCount <> 0 Then
If PrintDlg.Show Then
For Each cb In PrintDlg.CheckBoxes
If cb.Value = xlOn Then
Worksheets(cb.Caption).Activate
ActiveSheet.PrintOut

End If
Next cb
End If
Else
MsgBox "All worksheets are empty."
End If

Application.DisplayAlerts = False
PrintDlg.Delete

CurrentSheet.Activate
End Sub

mohammadkhorshi
2019/01/15, 19:56
دوست عزیز سلام

الان به صورتی هست که وقتی دکمه را میزنیم اگر ما 1000 تا شیت داشته باشیم یکم زشت میشه و اگه بخوایم همه رو پرینت بگیریم باید دونه دونه تیک بزنیم

امکانش هست وقتی دکمه رو میزنیم بالا اول از همه یک تیک all وجود داشته باشد؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟

ممنون