|
|
|
|
Bonjour,
mon code me permet de passer en PDF les fichier d'un dossier. Or je ne veux pas que le fichier "book1.xls" soit passé en pdf.
j'ai contourné le problème en sortant de la sub si une erreur survient (c'est le cas quand la macro essaie de passer book1.xls en PDF), mais ce n'est pas très "propre"
Comment sortir book1 de la boucle "proprement"? (je précise que mon code fonctionne bien en l'état.)
Public Sub CommandButton1_Click()
Application.ScreenUpdating = False
Application.EnableEvents = False
DisplayAlerts = False
Dim Fichier As String, Chemin As String
Dim Wb As Workbook
Chemin = ThisWorkbook.Path & "\"
Fichier = Dir(Chemin & "*.xls")
On Error GoTo Olive
Do Until Fichier = Dir(Chemin & "book1.xls")
Set Wb = Workbooks.Open(Chemin & Fichier)
Wb.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Chemin & Fichier, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Wb.Close (False)
Set Wb = Nothing
Fichier = Dir
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True
DisplayAlerts = True
Olive:
End Sub
Configuration: Windows XP Safari 532.0
Bonjour,
Chemin = ThisWorkbook.Path & "\" Fichier = Dir(Chemin & "*.xls") Do While (Fichier <> "") If Fichier <> Chemin & "book1.xls" Then Set Wb = Workbooks.Open(Fichier) Wb.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Chemin & Fichier, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _ :=False, OpenAfterPublish:=False Wb.Close (False) Set Wb = Nothing End If Fichier = Dir Loop ;o) «Ce que l'on conçoit bien s'énonce clairement, Et les mots pour le dire arrivent aisément.» Nicolas Boileau |
De rien,
|
Bonsoir tout le monde,
(Fichier <> "")donc tous les fichiers (mais teste dans la boucle si le nom est accepté). toi tu fais : jusqu'à ce que Fichier = Dir(Chemin & "book1.xls")"donc les fichiers qui arrivent après : walou... eric |