1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
| Private Sub Workbook_Open()
Dim butTop, butLeft, Bouton, butHeight, butWidth, Adresse
Dim k
Dim lastline, winindex
Dim ligne
Dim Name
Dim XlsFiles() As String
Dim DocFiles() As String
lastline = 1
ligne = 0
Application.DisplayAlerts = False
adress = ThisWorkbook.Path
'MkDir "C:\Documents and Settings\avaysse\Mes documents\sauvegarde"
XlsFiles = FindFiles(Adresse, "xls")
DocFiles = FindFiles(Adresse, "doc")
For i = LBound(XlsFiles) To UBound(XlsFiles)
If XlsFiles(i) = "test2.xls" Then GoTo sortie
Workbooks.Open Filename:= _
Adresse & XlsFiles(i)
Range("A1:N6").Select 'selection des cellules a copier
Selection.Copy ' copie des cellules
Workbooks("test2.xls").Worksheets(1).Cells(lastline, 1).PasteSpecial Paste:=xlFormats 'copie des format
Workbooks("test2.xls").Worksheets(1).Cells(lastline, 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Workbooks(("test2.xls")).Activate
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''affichage des %
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Range("h" & lastline + 5).Select
Selection.Font.ColorIndex = 1
Range("i" & lastline + 5).Select
Selection.Font.ColorIndex = 1
Range("j" & lastline + 5).Select
Selection.Font.ColorIndex = 1
Range("k" & lastline + 5).Select
Selection.Font.ColorIndex = 1
Range("l" & lastline + 5).Select
Selection.Font.ColorIndex = 1
Range("m" & lastline + 5).Select
Selection.Font.ColorIndex = 1
Selection.FormatConditions.Delete
Range("n" & lastline + 5).Select
Selection.Font.ColorIndex = 1
Selection.FormatConditions.Delete
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''' creation des liens vers les classeurs source
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''
'''' position du bouton ''''
'''''''''''''''''''''''''''''''''''
butTop = Range("g" & lastline + 7).Top
butLeft = Range("g" & lastline + 7).Left
butHeight = Range("g" & lastline + 7).Height
butWidth = Range("g" & lastline + 7).Width
'''''''''''''''''''''''''''''''''''
'''' code du bouton ''''
'''''''''''''''''''''''''''''''''''
Set Bouton = ActiveSheet.Buttons.Add(Left:=butLeft, Top:=butTop, Width:=butWidth, Height _
:=butHeight * 2)
With Bouton
.OnAction = "Openfiles"
Name = Split(XlsFiles(i), ".")
.Name = Name(0)
.Caption = "consulter"
End With
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''' creation des liens vers les documents word
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''
'''' position du bouton ''''
'''''''''''''''''''''''''''''''''''
butTop = Range("i" & lastline + 7).Top
butLeft = Range("i" & lastline + 7).Left
butHeight = Range("i" & lastline + 7).Height
butWidth = Range("i" & lastline + 7).Width
'''''''''''''''''''''''''''''''''''
'''' code du bouton ''''
'''''''''''''''''''''''''''''''''''
Set Bouton = ActiveSheet.Buttons.Add(Left:=butLeft, Top:=butTop, Width:=butWidth, Height _
:=butHeight * 2)
With Bouton
.OnAction = "OpenWorddocs"
Name = Split(XlsFiles(i), ".")
Name = Replace(Name(0), " ", "")
.Name = Name
Name = Split(XlsFiles(i), ".")
.Caption = "fiche projet"
End With
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''sauvegarde des documents excel
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''
'''' position du bouton ''''
'''''''''''''''''''''''''''''''''''
butTop = Range("k" & lastline + 7).Top
butLeft = Range("k" & lastline + 7).Left
butHeight = Range("k" & lastline + 7).Height
butWidth = Range("k" & lastline + 7).Width
'''''''''''''''''''''''''''''''''''
'''' code du bouton ''''
'''''''''''''''''''''''''''''''''''
Set Bouton = ActiveSheet.Buttons.Add(Left:=butLeft, Top:=butTop, Width:=butWidth, Height _
:=butHeight * 2)
With Bouton
.OnAction = "SaveFiles"
.Name = Name(0)
.Caption = "sauve et ouvre"
End With
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''' fermeture de toute les fenetres et vidé le clipboard
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Application.DisplayAlerts = False
Workbooks(XlsFiles(i)).Close False
OpenClipboard 0
EmptyClipboard
CloseClipboard
Application.DisplayAlerts = True
lastline = lastline + 10
sortie:
Next
Application.DisplayAlerts = True
End Sub |
Partager