Una famiglia di prodotti software per l'elaborazione di testo Microsoft per la creazione di documenti Web, messaggi di posta elettronica e stampa.
Ciao RobertoBellini,
allora la macro potrebbe essere questa:
Option Explicit
Public Sub Test2()
Const cstrProc = "Test2"
On Error GoTo ErrH
Const cstrPath = "" ' <--- Personalizzare.
'
' Esempi di personalizzazione della costante 'cstrPath':
'
' cstrPath = "" ' Salva come PDF nella stessa cartella del Documento
' ' Se il Documento non è ancora stato salvato, salva
' ' nella cartella predefinita.
' cstrPath = "D:\Pippo" ' Salva come PDF nel percorso specificato.
Dim wdDoc As Word.Document
Dim msoPrp As Office.DocumentProperty
Dim strPath As String
Dim strName As String
Dim p As String
Set wdDoc = ThisDocument
Set msoPrp = wdDoc.BuiltInDocumentProperties("Title")
If Len(msoPrp.Value) Then
strName = msoPrp.Value
Else
MsgBox "Impossibile salvare come PDF con Nome uguale al valore" _
& " della Proprietà 'Title'." _
& vbNewLine & "Non è ancora stato assegnato un valore" _
& " alla Proprietà 'Title'." _
, vbOKOnly Or vbExclamation _
, cstrProc
GoTo ExtP
End If
With wdDoc
If Len(cstrPath) Then
strPath = cstrPath
Else
If Len(.Path) Then
strPath = .Path
Else
strPath = .Application.Options.DefaultFilePath(wdDocumentsPath)
End If
End If
p = .Application.PathSeparator
If Right$(strPath, 1) <> p Then strPath = strPath & p
.ExportAsFixedFormat strPath & strName, wdExportFormatPDF
End With
ExtP:
On Error Resume Next
Set msoPrp = Nothing
Set wdDoc = Nothing
Exit Sub
ErrH:
With Err
MsgBox "ERR#" & CStr(.Number) _
& vbNewLine & .Description _
, vbOKOnly Or vbCritical _
, cstrProc
End With
Resume ExtP
End Sub