bouton imprimer

zepeto

XLDnaute Occasionnel
Bonjour à tous.
Je suis sous excel 97 et j'ai une macro avec des userform et un bouton imprimer qui lance l'impression d'une feuille de mon classeur exel, je demande également à l'utilisateur de dire combien de fois il veut imprimer le document mais si il click sur annuler sa plante et je ne voi pas comment résoudre ceux probléme?
Merci par avance de votre aide et je suis disponible pour toutes autres informations
voici mon code :

i = InputBox("Veuillez saisir le nombre d'impression désirée")
'ActiveWindow.SelectedSheets.PrintPreview 'aperçu
ActiveWindow.SmallScroll Down:=-39
ActiveWindow.SelectedSheets.PrintOut Copies:=i, Collate:=True 'impression
ActiveWindow.SmallScroll Down:=9
 
C

Compte Supprimé 979

Guest
Re : bouton imprimer

Salut Zepeto,

Il faut tester la valeur de "i" comme tu l'utilises dans ton impression

Code:
i = InputBox("Veuillez saisir le nombre d'impression désirée")
'ActiveWindow.SelectedSheets.PrintPreview 'aperçu
[COLOR=blue]If i = "" Then Exit Sub
If Not IsNumeric(i) Then
  MsgBox "Le nombre d'impression doit être un chiffre !"
  Exit Sub
End If
[/COLOR]ActiveWindow.SmallScroll Down:=-39
ActiveWindow.SelectedSheets.PrintOut Copies:=i, Collate:=True 'impression
ActiveWindow.SmallScroll Down:=9

Voilà ;)
 

gilbert_RGI

XLDnaute Barbatruc
Re : bouton imprimer

Bonjour

Comme ceci

Sub test()
i = InputBox("Veuillez saisir le nombre d'impression désirée")
If i = Cancel Then Exit Sub
'ActiveWindow.SelectedSheets.PrintPreview 'aperçu

ActiveWindow.SelectedSheets.PrintOut Copies:=i, Collate:=True 'impression

End Sub

Cdlt

RGI
 

zepeto

XLDnaute Occasionnel
Re : bouton imprimer

Merci.
Bruno M45 j'ai testé ta valeur mais je ne sais pas comment dire ne pas imprimer pour les valeurs negatives et les chiffres ou il y a un point devant?


i = InputBox("Veuillez saisir le nombre d'impression désirée", "Impression")
'ActiveWindow.SelectedSheets.PrintPreview 'aperçu
If i = "" Or i = 0 Then
Exit Sub
Call Initialise_imprimer
End If
If Not IsNumeric(i) Then
MsgBox "Le nombre d'impression doit être un chiffre !"
Exit Sub
End If
ActiveWindow.SmallScroll Down:=-39
ActiveWindow.SelectedSheets.PrintOut Copies:=i, Collate:=True 'impression
ActiveWindow.SmallScroll Down:=9
 
G

Guest

Guest
Re : bouton imprimer

bonjour Zepeto,

Patiente...ça arrive.

Code:
[COLOR=#0000ff]If i = "" Then Exit Sub
If Not IsNumeric(i) Then
  MsgBox "Le nombre d'impression doit être un chiffre !"
  Exit sub[/COLOR]
[COLOR=#0000ff]endif[/COLOR]
 
[COLOR=#0000ff]'Si il y a un point ou une virgule[/COLOR]
[COLOR=#0000ff]if instr(I,".")>0 or Instr(i,",")>0  then[/COLOR]
[COLOR=#0000ff]  MsgBox "Entrez un nombre entier sans point ni virgule"[/COLOR]
[COLOR=#0000ff]  Exit Sub[/COLOR]
[COLOR=#0000ff]End If[/COLOR]
 
[COLOR=#0000ff]i=abs(Val(i)) 'Convertit i en absolu (donc sans moins devant)[/COLOR]
 
[COLOR=#0000ff]' Si i vaut 0[/COLOR]
[COLOR=#0000ff]If i<=0 then[/COLOR]
[COLOR=#0000ff]   Exit Sub[/COLOR]
[COLOR=#0000ff]EndIF[/COLOR]

A bientôt
 

Statistiques des forums

Discussions
312 337
Messages
2 087 392
Membres
103 534
dernier inscrit
Kalamymustapha