with "NomDeTaFeuille"
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
end with
Cells.Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 2
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 2
End With
ActiveWindow.DisplayGridlines = False
Cells.Borders.LineStyle = xlNone
ActiveWindow.DisplayGridlines = False
Private Sub CommandButton4_Click()
' copy sur la feuille FactureClients
Call SaveInfos(Sheets("Facture"), Sheets("FactureClients"), lRow)
'évite les basculements d'écrans
Application.ScreenUpdating = False
' bouton valider
nomfichier = ActiveWorkbook.Name
'ouverture nouveau classeur - 1 feuille - ne fonctionne pas sous XL97
défaut = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Workbooks.Add
Application.SheetsInNewWorkbook = défaut
nomfichier1 = ActiveWorkbook.Name
'copie la feuille
Windows(nomfichier).Activate
Range("Zoneimpression").Copy
'colle dans nouveau fichier
Windows(nomfichier1).Activate
ActiveSheet.Range("A1").Select
ActiveSheet.Paste
'protège les cellules
ActiveSheet.Range(Selection.Address).Locked = True
ActiveSheet.Range("A1").Select
'enregistre sous le répertoire Factures, selon numéro de facture
ChDir (ThisWorkbook.Path & "\Dossier_Factures")
'choix avec nom par défaut, possibilité de changer le nom ou annuler
'enregistrer avec le nom et le N° de facture
fermer = Application.GetSaveAsFilename(ActiveSheet.Range("I16") & "_" & ActiveSheet.Range("C11"), "Fichiers Excel,*.xls")
'si annulation
If fermer = False Then
Windows(nomfichier1).Activate
ActiveWorkbook.Close Savechanges:=False
Exit Sub
End If
'sinon
ActiveWorkbook.SaveAs FileName:=fermer
ActiveWorkbook.Close
'retour sur modèle
'raz champ Aremplir
Range("Aremplir").ClearContents
'réautorise les basculements d'écran
Application.ScreenUpdating = True
Private Sub CommandButton4_Click()
' copy sur la feuille FactureClients
Call SaveInfos(Sheets("Facture"), Sheets("FactureClients"), lRow)
'évite les basculements d'écrans
Application.ScreenUpdating = False
' bouton valider
nomfichier = ActiveWorkbook.Name
'ouverture nouveau classeur - 1 feuille - ne fonctionne pas sous XL97
défaut = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Workbooks.Add
Application.SheetsInNewWorkbook = défaut
nomfichier1 = ActiveWorkbook.Name
'copie la feuille
Windows(nomfichier).Activate
Range("Zoneimpression").Copy
'colle dans nouveau fichier
Windows(nomfichier1).Activate
ActiveSheet.Range("A1").Select
ActiveSheet.Paste
'protège les cellules
ActiveSheet.Range(Selection.Address).Locked = True
ActiveSheet.Range("A1").Select
'enregistre sous le répertoire Factures, selon numéro de facture
ChDir (ThisWorkbook.Path & "\Dossier_Factures")
'choix avec nom par défaut, possibilité de changer le nom ou annuler
'enregistrer avec le nom et le N° de facture
fermer = Application.GetSaveAsFilename(ActiveSheet.Range("I16") & "_" & ActiveSheet.Range("C11"), "Fichiers Excel,*.xls")
'si annulation
If fermer = False Then
Windows(nomfichier1).Activate
ActiveWorkbook.Close Savechanges:=False
Exit Sub
End If
'sinon
ActiveWorkbook.SaveAs FileName:=fermer
ActiveWorkbook.Close
'retour sur modèle
'raz champ Aremplir
Range("Aremplir").ClearContents
'réautorise les basculements d'écran
Application.ScreenUpdating = True
End Sub
Private Sub BtnLister_Click()
'Ou en cliquant sur ce bouton
Call Test
End Sub
Private Sub ListBox1_Click()
If ListBox1.ListIndex <> -1 Then
Workbooks.Open FileName:=ThisWorkbook.Path & "\Dossier_Factures\" & ListBox1.Text
Unload Me
End If
End Sub
Sub Test()
Const ssfTous = &H1
Dim objShell As Object, objFolder As Object, oFolderItem As Object
'Ici le ThisWorkbook est le chemin de ce fichier
Chemin = ThisWorkbook.Path & "\Dossier_Factures"
UserForm2.ListBox1.Clear
UserForm2.Label1.Caption = Chemin
Lister 1, UserForm2.Label1.Caption
End Sub
Sub Lister(nRow&, FolderName$, Optional Suffix$ = "*.*", Optional SubDir As Boolean = True)
Dim i As Long, x As Long, File As String, Folder As String, nbFolders() As String
Application.ScreenUpdating = False
nRow = nRow + 1
If Not Right(FolderName, 1) = "\" Then FolderName = FolderName & "\"
File = Dir(FolderName & Suffix)
Do While Len(File) > 0
UserForm2.ListBox1.AddItem File
nRow = nRow + 1: File = Dir
Loop
If Not SubDir Then Exit Sub
x = 0: Folder = Dir(FolderName, vbDirectory)
Do While Folder > ""
If Folder <> "." And Folder <> ".." Then
If (GetAttr(FolderName & Folder) And vbDirectory) = vbDirectory Then x = x + 1
End If
Folder = Dir
Loop
ReDim nbFolders(x + 1): i = 1
nbFolders(i) = Dir(FolderName, vbDirectory)
Do While nbFolders(i) > ""
If nbFolders(i) <> "." And nbFolders(i) <> ".." Then
If (GetAttr(FolderName & nbFolders(i)) And vbDirectory) = vbDirectory Then i = i + 1
End If
nbFolders(i) = Dir
Loop
For i = 1 To UBound(nbFolders()) - 1
Call Lister(nRow, FolderName & nbFolders(i), Suffix)
Next
Set objShell = Nothing
Set objFolder = Nothing
Set oFolderItem = Nothing
End Sub