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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
| Private Sub ConcatenerFindings()
Dim j As Byte
Dim NumeroDerniereLigneCelluleNonVide As Integer
With Sheets("Finding report")
NumeroDerniereLigneCelluleNonVide = Range("A300").End(xlUp).Row
'AdresseDerniereCelluleNonVide = Range("A21:A300").Find("*", , xlFormulas, xlWhole, xlByRows, xlPrevious)
'NumeroDerniereLigneCelluleNonVide = AdresseDerniereCelluleNonVide.Row 'Range("A" & NoLigne).End(xlUp).Row
'Cells(400, 1).End(xlUp).Row
'Range.Find("*", Range("A20"), xlValues, xlPart, xlByRows, xlPrevious, False).Value
'Range("A600").End(xlUp).Row
For j = 21 To NumeroDerniereLigneCelluleNonVide
If Cells(j, 1) <> "" Then
.Cells(j, 12) = .Cells(j, 1) & "" & "" & "" & .Cells(j, 2) & "" & "" & "" & .Cells(j, 3) & "" & "" & "" & .Cells(j, 6)
Else
.Cells(j, 12) = ""
End If
Next j
End With
End Sub
Private Sub CopierDonneesPartieFindings()
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Dim i, j As Byte
Dim LigneProchaineCelluleNonVide As Integer
Dim DerniereCelluleNonVide As Range
'Dim CelluleConcateneeActuelle As Range
Dim ValeurProchCelluleNonVide As Variant
i = 1
j = 21
Set WordApp = CreateObject("word.application") 'ouvre session word
Set WordDoc = WordApp.Documents.Open("C:\Users\Utilisateur\Desktop\SIN-ENG-P04-F02_maintenance_work_sheet_ANNEX Revision 1.docx") 'ouvre document Word
With Sheets("Finding Report")
Do While Cells(j, 12) <> ""
WordDoc.Bookmarks("Signet" & i).Range.Text = Cells(j, 12)
i = i + 1
j = j + 1
Loop
For i = i To 11
'CelluleConcateneeActuelle = Cells(j, 12)
LigneProchaineCelluleNonVide = Range("Cells(j, 12)").End(xlDown).Row
DerniereCelluleNonVide = Range(LigneProchaineCelluleNonVide, 12)
ValeurProchCelluleNonVide = DerniereCelluleNonVide.Value
WordDoc.Bookmarks("Signet" & i).Range.Text = ValeurProchCelluleNonVide
j = LigneProchaineCelluleNonVide
Next i
'ValeurProchCelluleNonVide = Column(12).Find("*", Range("Cells(j, 12)"), xlValues, , 2, 1, 0).Value
'WordDoc.Bookmarks("Signet" & i).Range.Text = Column(12).Find("*", Range("ValeurProchCelluleNonVide.Adress"), xlValues, , 2, 1, 0).Value
'Range("A20:A" & Cells(Rows.Count, 1).End(xlUp).Row).SpecialCells(xlCellTypeConstants).Copy
'WordDoc.Bookmarks("Signet" & i).PasteSpecial (xlPasteValues)
End With
End Sub
Private Sub ConcatenerDefectivePartsRequired()
With Sheets("Finding report")
Dim CelluleReference As Variant
Dim ReceptionsConcatenees As String
Dim Reference As String
Dim j, X, k As Byte
j = 21
X = 1
k = 21
DerniereLigneNonVide = Range("G" & Rows.Count).End(xlUp).Row
Set PlageReference = Range(Cells(21, 7), Cells(DerniereLigneNonVide, 7))
CelluleReceptionsConcatenees = Cells(k, 14)
CelluleReference = Cells(j, 7)
Reference1 = "Normal wear & tear"
Reference2 = "Misuse/mishandeling"
Reference3 = "SUP"
Reference4 = "FOD"
For X = 1 To 4
For Each CelluleReference In PlageReference
If CelluleReference = ("Reference" & X) & CelluleReference <> "" Then
CelluleReceptionsConcatenees = CelluleReceptionsConcatenees & CelluleReference.Offset(0, -6) & " / "
End If
Next CelluleReference
k = k + 1
Next X
End With
End Sub
Private Sub CopierDonneesDefectivePartsRequired()
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Dim i, j As Byte
Set WordApp = CreateObject("word.application") 'ouvre session word
Set WordDoc = WordApp.Documents.Open("C:\Users\MOUNSI\Desktop\SIN-ENG-P04-F02_maintenance_work_sheet_ANNEX Revision 1.docx") 'ouvre document Word
With Sheets("Finding Report")
i = 12
j = 21
Do While Cells(j, 14) <> ""
WordDoc.Bookmarks("Signet" & i).Range.Text = Cells(j, 14)
If i = 22 Then
Exit Do
End If
i = i + 1
j = j + 1
Loop
End Sub
Private Sub ConcatenerWorkPerformed()
Dim j As Byte
With Sheets("Finding report")
NumeroDerniereLigneCelluleNonVide = Cells(Rows.Count, 3).End(xlUp).Row
'Range.Find("*", Range("A20"), xlValues, xlPart, xlByRows, xlPrevious, False).Value
'Range("A600").End(xlUp).Row
For j = 21 To NumeroDerniereLigneCelluleNonVide
If Cells(j, 3) <> "" Then
.Cells(j, 16) = "New" & .Cells(j, 3) & "installed"
Else
.Cells(j, 16) = ""
Next j
End With
End Sub
Private Sub CopierDonneesWorkPerformed()
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Dim i, j As Byte
i = 23
j = 21
Set WordApp = CreateObject("word.application") 'ouvre session word
Set WordDoc = WordApp.Documents.Open("C:\Users\MOUNSI\Desktop\SIN-ENG-P04-F02_maintenance_work_sheet_ANNEX Revision 1.docx") 'ouvre document Word
With Sheets("Finding Report")
Do While Cells(j, 16) <> ""
WordDoc.Bookmarks("Signet" & i).Range.Text = Cells(j, 16)
i = i + 1
j = j + 1
Loop
For i = i To 35
AdresseDerniereCelluleNonVide = Worksheets("Finding report").Range("Cells(j, 16):L").Find("*", , xlValues, , , xlPrevious)
ValeurProchCelluleNonVide = AdresseDerniereCelluleNonVide.Value
WordDoc.Bookmarks("Signet" & i).Range.Text = ValeurProchCelluleNonVide
j = AdresseDerniereCelluleNonVide.Row
Next i
'ValeurProchCelluleNonVide = Column(12).Find("*", Range("Cells(j, 12)"), xlValues, , 2, 1, 0).Value
'WordDoc.Bookmarks("Signet" & i).Range.Text = Column(12).Find("*", Range("ValeurProchCelluleNonVide.Adress"), xlValues, , 2, 1, 0).Value
'Range("A20:A" & Cells(Rows.Count, 1).End(xlUp).Row).SpecialCells(xlCellTypeConstants).Copy
'WordDoc.Bookmarks("Signet" & i).PasteSpecial (xlPasteValues)
End With
End Sub
Sub ExportdonneesversWord()
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Dim i As Byte
Dim j As Byte
Set WordApp = CreateObject("word.application") 'ouvre session word
Set WordDoc = WordApp.Documents.Open("C:\Users\MOUNSI\Desktop\SIN-ENG-P04-F02_maintenance_work_sheet_ANNEX Revision 1.docx") 'ouvre document Word
WordApp.Visible = True 'word masqué pendant l'operation
While WordDoc.Bookmarks("Signet11").Range.Text = ""
ConcatenerFindings '
CopierDonneesPartieFindings '
Wend
While WordDoc.Bookmarks("Signet22").Range.Text = ""
ConcatenerDefectivePartsRequired '
CopierDonneesDefectivePartsRequired '
Wend
While WordDoc.Bookmarks("Signet35").Range.Text = ""
ConcatenerWorkPerformed '
CopierDonneesWorkPerformed '
Wend
'If WordDoc.Bookmarks("Signet11").Range.Text <> "" Then
'Set WordApp = CreateObject("word.application") 'ouvre session word
'Set WordDoc = WordApp.Documents.Open("C:\Users\MOUNSI\Desktop\SIN-ENG-P04-F02_maintenance_work_sheet_ANNEX Revision 1.docx") 'ouvre document Word
'Concatener '
'CopierDonneesPartieFindings '
'End If
WordApp.Visible = True 'affiche le document Word
'WordDoc.PrintOut 'imprimer
'WordDoc.Close True 'ferme le document word en sauvegardant les données
'WordApp.Quit 'ferme la session Word
End Sub |
Partager