Workbook Private Sub Command1_Click()Set Xl = New Excel. Protect Structure Then Msg Box "Workbook is protected.", vb Critical Exit Sub End If' Add a temporary dialog sheet Set Current Sheet = Active Sheet Set Print Dlg = Active Workbook. Add Sheet Count = 0' Add the checkboxes Top Pos = 40 For i1 = 1 To Active Workbook.
Screen Updating = False' Check for protected workbook If Active Workbook. Worksheets(i1)' Skip empty sheets and hidden sheets If Application.
For deleting all sheets in an Excel workbook except specified one or current active sheet, you can deal with this as below methods shown.
Delete all sheets except specified one with VBA code One click to delete all sheets except current active one with Kutools for Excel Delete All Inactive Sheets. Then a dialog box pops up, if you determine to delete all sheets except active one, click the OK button, otherwise, click the Cancel button.
I was in a forum recently, when I came across a question on how to get or read data from a closed excel workbook (file) without actually opening it. I have an Excel file (the source), where I regularly update the Sales figures for each region.
In-addition, I have another excel file, which would automatically get the figures from the source file, without opening it. Open("C:\Q-SALES.xlsx", True, True) Once I get the data, I’ll count the number of rows in the source workbook.
.action_button.action_button:active.action_button:hover.action_button:focus,.action_button:hover.action_button:focus .count,.action_button:hover .count.action_button:focus .count:before,.action_button:hover .count:bullet. Caption = "Select sheets to print" End With' Change tab order of OK and Cancel buttons' so the 1st option button will have the focus Print Dlg. Bring To Front' Display the dialog box Current Sheet. Screen Updating = True If Sheet Count End If Else Msg Box "All worksheets are empty." End If' Delete temporary dialog sheet (without a warning) Application. Here's the code I used: Public Sub Command1_Click() Dim Wk Sheet As Worksheet Set Wk Sheet = Active Workbook. Protect Structure Then Msg Box "Workbook is protected.", vb Critical Exit Sub End If' Add a temporary dialog sheet Set Current Sheet = Active Sheet Set Print Dlg = Active Workbook. Add Sheet Count = 0' Add the checkboxes Top Pos = 40 For i1 = 1 To Active Workbook. Activate End Sub Unfortunately I don't have VB6, but I did run your code in excel (VBA) and it seemed fine to me, so I'm not sure what the problem is. Application Dim CWB As Workbook 'Set CWB = Workbooks. Screen Updating = False' Check for protected workbook If Active Workbook. Worksheets(i1)' Skip empty sheets and hidden sheets If Application. Open ("D:\Pay Project\Print Pay Slips07\Paystub Jun2007.xls") Set CWB = Workbooks. Activate Dim i1 As Integer Dim Top Pos As Integer Dim Sheet Count As Integer Dim Print Dlg As Dialog Sheet Dim Current Sheet As Worksheet Dim cb As Check Box Application. Visible Then Sheet Count = Sheet Count 1 Print Dlg.