Modif code pour impression

Gix

XLDnaute Occasionnel
Bonjour le Forum,

Je souhaiterai modifier le code afin de pouvoir saisir la valeur zéro ( ne pas imprimer la feuille facture ) tout en continuant l'exécution de ma commande.
Est-ce possible? Si oui pouvez-vous me venir en aide .
Vous remerciant tous par avance.

Bonne journée, Gix.

[Sub DocuementValider()
Dim vNbreImp As Variant
Dim DocFch As Variant
Dim DocChm As Variant
DocFch = Range('DocFch')
DocChm = Range('DocChm')

If Range('DocNumDoc') = '' Then
informer = MsgBox('Numero Facture obligatoire !', vbOKOnly, 'Ajout impossible / FactureGix')
Range('DocNumDoc').Select
Exit Sub
End If

If Range('RvNomClient') = '' Then
informer = MsgBox('Nom du Client obligatoire !', vbOKOnly, 'Ajout impossible / FactureGix')
Range('RvNomClient').Select
Exit Sub
End If

vNbreImp = InputBox('Nombre d'exemplaire à imprimer :', 'Impression Document / FactureGix', 1)
If vNbreImp <= 0 Then GoTo 5
If IsNumeric(vNbreImp) Then
GoTo 10
Else: Do Until IsNumeric(vNbreImp)
5
MsgBox 'La valeur doit être un nombre entier et > 0'
vNbreImp = InputBox('Nombre d'exemplaire à imprimer :', 'Impression Document / FactureGix', 1)
Loop
GoTo 10
End If
10
Sheets('Facture').Select
ActiveWindow.SelectedSheets.PrintOut Copies:=vNbreImp

If Range('DossierOptCopieDoc') = 'Non' Then GoTo 20

If Range('DossierOptCopieDoc') = 'Oui' Then
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=DocChm, _
FileFormat:=xlNormal, Password:='', WriteResPassword:='', _
ReadOnlyRecommended:=False, CreateBackup:=False
Windows('FactureGix.xls').Activate
Sheets('Facture').Select
Cells.Select
Selection.Copy
Windows(DocFch).Activate
Cells.Select
Selection.PasteSpecial Paste:=xlValues, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Range('a1').Select
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWorkbook.Close
GoTo 20
End If
20
Windows('FactureGix.xls').Activate
Sheets('Document').Unprotect Password:='gix'
Range('DossierNumDoc') = Range('DossierNumDoc') + 1
Sheets('Document').Select
Range('DocNumDoc') = Range('DossierNumDoc')
Range('RefDocSaisie').Select
Selection.ClearContents

Range('b13').Select
Sheets('Document').Protect Password:='gix'
ActiveWorkbook.Save
End Sub]
 

Robert

XLDnaute Barbatruc
Repose en paix
Bonjour Gix, bonjour le forum,

En gras les modifs que j'ai faites. Non testées bien sûr à cause de grande flemme de recréer tes conditions. J'espère que c'est ça que tu veux. Sinon j'ai de l'eau fraîche et du pastaga... c'est quand tu veux avant le 21 juillet ou après le 15 août...



Sub DocuementValider()
Dim vNbreImp As Byte
Dim DocFch As String
Dim DocChm As String

DocFch = Range('DocFch')
DocChm = Range('DocChm')

If Range('DocNumDoc') = '' Then
informer = MsgBox('Numero Facture obligatoire !', vbOKOnly, 'Ajout impossible / FactureGix')
Range('DocNumDoc').Select
Exit Sub
End If

If Range('RvNomClient') = '' Then
informer = MsgBox('Nom du Client obligatoire !', vbOKOnly, 'Ajout impossible / FactureGix')
Range('RvNomClient').Select
Exit Sub
End If

vNbreImp = InputBox('Nombre d'exemplaire à imprimer :', 'Impression Document / FactureGix', 1)
If vNbreImp = 0 Then GoTo 15
If vNbreImp <= 0 Then GoTo 5
If IsNumeric(vNbreImp) Then
GoTo 10
Else: Do Until IsNumeric(vNbreImp)
5
MsgBox 'La valeur doit être un nombre entier et > 0'
vNbreImp = InputBox('Nombre d'exemplaire à imprimer :', 'Impression Document / FactureGix', 1)
Loop
GoTo 10
End If
10
Sheets('Facture').Select
ActiveWindow.SelectedSheets.PrintOut Copies:=vNbreImp
15
If Range('DossierOptCopieDoc') = 'Non' Then GoTo 20

If Range('DossierOptCopieDoc') = 'Oui' Then
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=DocChm, _
FileFormat:=xlNormal, Password:='', WriteResPassword:='', _
ReadOnlyRecommended:=False, CreateBackup:=False
Windows('FactureGix.xls').Activate
Sheets('Facture').Select
Cells.Select
Selection.Copy
Windows(DocFch).Activate
Cells.Select
Selection.PasteSpecial Paste:=xlValues, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Range('a1').Select
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWorkbook.Close
GoTo 20
End If
20
Windows('FactureGix.xls').Activate
Sheets('Document').Unprotect Password:='gix'
Range('DossierNumDoc') = Range('DossierNumDoc') + 1
Sheets('Document').Select
Range('DocNumDoc') = Range('DossierNumDoc')
Range('RefDocSaisie').Select
Selection.ClearContents

Range('b13').Select
Sheets('Document').Protect Password:='gix'
ActiveWorkbook.Save
End Sub
 

Gix

XLDnaute Occasionnel
Bonjour le forum et mon ami Robert,

Que faut-il dire de plus , tu n'as pas besoin de tester et bien évidemment que ça marche.
J'aurai une faveur à te demander pourrais-tu donné un coup d'oeil concernant ce sujet Lien supprimé
histoire de savoir si la modif que j'ai faite est correcte, tu sais que je ne suis pas un grand connaisseur en vba c'est pour cela que je te demande ton avis,svp.

Je te remercie par avance, Gix.

PS:

Attention,pour l'eau fraîche et le pastaga je prends au mot, par contre tu dois obligatoirement prendre un chocolat trés chaud!!! ( avec beaucoup de cacao ou pas ?)

A + Gix.
 

Discussions similaires

Statistiques des forums

Discussions
312 499
Messages
2 088 999
Membres
104 001
dernier inscrit
dessinbecm