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
|
Sub ToPdf2()
Dim oDlg As FileDialog
Dim nomWord As String
'utilisation d'une boîte de dialogue pour récupérer un répertoire
Set oDlg = Application.FileDialog(msoFileDialogFolderPicker)
If ActiveDocument.Bookmarks.Exists("Titre") = True Then
Else: MsgBox "Erreur, le signet titres n'existe pas", vbOKOnly, "Erreur"
'Sortie de la procédure si le signet n'existe pas
Exit Sub
End If
If ActiveDocument.Bookmarks.Exists("Code") = True Then
Else: MsgBox "Erreur, le signet Code n'existe pas", vbOKOnly, "Erreur"
'Sortie de la procédure si le signet n'existe pas
Exit Sub
End If
'Affichage de la boîte de dialogue
With oDlg
.AllowMultiSelect = False
.InitialFileName = "C:\Documents and Settings\All Users\Documents\QUALITE\DOCUMENTATION SMQ\MANUEL QUALITE\DOCUMENTS ACTIFS\"
.Show
End With
'Avant : NomWord = ActiveDocument.Name
'Pas besoin d'utiliser une seconde variable pour le nom du fichier
nomWord = ActiveDocument.Bookmarks("Titre").Range.Text & "-" & ActiveDocument.Bookmarks("Code").Range.Text
nomWord = Left(nomWord, Len(nomWord) - 4) & ".pdf"
'concaténation du résultat de la boîte de dialogue et du nomWord obtenu plus tôt
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
oDlg.SelectedItems(1) & nomWord _
, ExportFormat:=wdExportFormatPDF, OpenAfterExport:=True, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
End Sub |
Partager