Sub test()
Dim chemin$, x As Boolean, wordapp As Object, part$
x = ActiveCell.Column = 1 'determine un boolean selon si la colonne active est la "A"
part = Sheets(1).Cells(ActiveCell.Row, "E") ' partie du nom dans la colonne "E" de la meme ligne
chemin = "C:\Users\" & Environ("username") & "\Desktop\" & part & " (barcode).docx" 'chemin
If Dir(chemin) = "" Then MsgBox "ce fichier n'existe pas": Exit Sub ' test de l'existance du fichier avant d'essayer de l'ouvrir
If x Then
Application.ScreenUpdating = False
Set wordapp = CreateObject("word.Application")
wordapp.documents.Open chemin
wordapp.Visible = True
Sheets(1).Cells(ActiveCell.Row, "E").Font.Size = 85
Sheets(1).Cells(ActiveCell.Row, "E").Copy
wordapp.activedocument.Range.PasteSpecial (xlPasteValues)
Sheets(1).Cells(ActiveCell.Row, "E").Font.Size = 11
With Application: .CutCopyMode = False: .DisplayAlerts = False: End With
With wordapp.Application: .activedocument.SaveAs chemin: .Quit: End With
Application.DisplayAlerts = True
Else
MsgBox "Please select a reference number"
End If
End Sub