Option Explicit
Private Sub Document_Open()
CustomizationContext = ActiveDocument
KeyBindings.Add _
KeyCode:=BuildKeyCode(wdKeyControl, wdKeyM), _
KeyCategory:=wdKeyCategoryCommand, _
Command:="Export"
If Err = 0 Then MsgBox "La macro ""Export"" a été assignée aux touches CTRL+M"
End Sub
Sub Export()
Dim NomFich As String
NomFich = Split(ActiveDocument.FullName, "-")(0) & "-P.pdf"
ActiveDocument.ExportAsFixedFormat NomFich, wdExportFormatPDF
If Err = 0 _
Then MsgBox NomFich & vbLf & "a été enregistré ", vbInformation _
Else MsgBox NomFich & vbLf & Err.Description, vbCritical
Application.DisplayAlerts = False
Application.Quit wdSaveChanges
End Sub
Private Sub Document_Close()
FindKey(BuildKeyCode(wdKeyControl, wdKeyM)).Disable
End Sub