I have a workbook with several sheets, some of which are going to be printed at once, eighther to a .pdf file or to a paper. Doing so, there are several dialogs that are shown, for example:
Dialog PrinterSetup to choose the printer. Dialog Save PDF file as, in the case of a .pdf, to choose where to save the document. Dialog Confirm Save to confirm the operation, of course. Dialog Adobe PDF that shows the addition of sheets to the final document.
I am not sure, but only the first one is really an Application.Dialogs, the others are not, at least they do not appear in the VBA list as one.
All of the dialogs have a "Cancel" button, to cancel the printing. My code can detect if the Dialog PrinterSetup Cancel button has been clicked, but that it is. I DO NOT KNOW HOW TO DETECT if SOME OF THE OTHER IS PUSHED. I need help to figure out this.
Thanks.
Here is my code:
HTML Code:
Private Sub TODOSBtn_Click()
Dim resp As Integer
Dim ws As Worksheet
On Error GoTo 10
PrintBORRAR
PrintBORRAVALUES
resp = MsgBox("Desea imprimir todos los costos de producción? ", vbYesNo + vbExclamation, "ALERTA")
If resp = 7 Then
TODOSBtn.Value = False
Exit Sub
End If
Dim answ As Boolean
answ = Application.Dialogs(xlDialogPrinterSetup).Show
If answ = True Then
Sheets(Array("AJONJOLI LABRANZA COMPLETA", "ALGODON LABRANZA COMPLETA", "ARROZ INV. LLANOS OCCIDENTALES", _
"ARROZ VER. LLANOS CENTRALES", "CAÑA PLANTILLA MECANICA", "CAÑA PLANTILLA MANUAL", "CAÑA SOCA MECANICA", _
"CAÑA SOCA MANUAL", "CARAOTA LABRANZA COMPLETA OCC", "CARAOTA SIN LABRANZA CENTRORIEN", _
"CEBOLLA LLANOS CENTRA LABR COMP", "CEBOLLA ANDES LABR DE SANGRE", "FRIJOL SIN LABRANZA", _
"FRIJOL LABRANZA COMPLETA", "GIRASOL LABRANZA COMPLETA", "GIRASOL SIN LABRANZA", _
"LECHUGA ANDES LABR SANGR COMPLE", "MAIZ LABRANZA COMPLET OCCIDENTE", "MAIZ LABRANZA MINIMA LLANOS CEN", _
"MAIZ SIN LABRANZA LLANOS CENTRA", "NARANJA FUNDACION", "NARANJA MANTENIMIENTO 2", "NARANJA MANTENIMIENTO 3", _
"NARANJA MANTENIMIENTO > 3", "PAPA ANDES LABR DE SANGRE", "PAPA CENTRO OCC LABR COMPLETA", _
"PIMENTON ANDES LABR SANGR COMPL", "REMOLACH ANDES LABR SANG COMPLE", "REPOLLO ANDES LABR SANGR COMPL", _
"SORGO INV LABRANZA COMPLETA", "SORGO INV LABRANZA MINIMA", "SORGO INV SIN LABRANZA", _
"SORGO NORTE VERANO OCCIDENTE", "SOYA SIN LABRANZA", "TOMATE INDUSTRIAL LLANO CENTRAL", _
"TOMATE CONS DIREC LLANO CENTRAL", "TOMATE CONS DIREC ANDES LABR CO", "ZANAHO ANDES LABR SANGRE COMPLE")).PrintOut ' , , 1
Else
MsgBox "La impresión fue cancelada.", vbOKOnly + vbExclamation, "OPERACIÖN CANCELADA"
TODOSBtn.Value = False
Exit Sub
End If
Exit Sub
10:
MsgBox "Se ha presentado un problema con la impresión.", vbOKOnly + vbExclamation, "ALERTA"
TODOSBtn.Value = False
Exit Sub
End Sub
Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
Hello, My Friends:
I have a workbook with several sheets, some of which are going to be printed at once, eighther to a .pdf file or to a paper. Doing so, there are several dialogs that are shown, for example:
Dialog PrinterSetup to choose the printer.
Dialog Save PDF file as, in the case of a .pdf, to choose where to save the document.
Dialog Confirm Save to confirm the operation, of course.
Dialog Adobe PDF that shows the addition of sheets to the final document.
I am not sure, but only the first one is really an Application.Dialogs, the others are not, at least they do not appear in the VBA list as one.
All of the dialogs have a "Cancel" button, to cancel the printing. My code can detect if the Dialog PrinterSetup Cancel button has been clicked, but that it is. I DO NOT KNOW HOW TO DETECT if SOME OF THE OTHER IS PUSHED. I need help to figure out this.
Thanks.
Here is my code: