From: Paul Moloney on
I'm trying to create a macro which does some checks on a document (for
example, refreshes all fields and checks for broken x-refs by searching for
the text "Error!") before PDFing it.

Does anyone know what VBA will perform the same task performed by clicking
the Acrobat-->Create PDF option?

Also, if anyone know of any similar macros that perform error-checking on
Word document, please let me know,

Thanks,

P.

From: Graham Mayor on
To create a PDF from Word using the Acrobat add-in by vba, you could use
something like the following. You will need to set a reference to the
AdobePDFMakerForOffice object library in the vba editor. Or you could use
the Office 2007 PDF plug-in and save the document as PDF.

Option Explicit
Sub ConvertToPDF()
Dim pdfname, i, a
Dim pmkr As AdobePDFMakerForOffice.PDFMaker
Dim stng As AdobePDFMakerForOffice.ISettings

With ActiveDocument
'The document must be saved - so save it!
.Save
Set pmkr = Nothing ' locate PDFMaker object
For Each a In Application.COMAddIns
If InStr(UCase(a.Description), "PDFMAKER") > 0 Then
Set pmkr = a.Object
Exit For
End If
Next
If pmkr Is Nothing Then
MsgBox "Cannot Find PDFMaker add-in", vbOKOnly, ""
Exit Sub
End If
pdfname = Left(.name, InStrRev(.name, ".")) & "pdf"
' delete PDF file if it already exists
If Dir(pdfname) <> "" Then Kill pdfname
pmkr.GetCurrentConversionSettings stng
stng.AddBookmarks = True ' make desired settings
stng.AddLinks = True
stng.AddTags = False
stng.ConvertAllPages = True
stng.CreateFootnoteLinks = True
stng.CreateXrefLinks = True
stng.OutputPDFFileName = pdfname
stng.PromptForPDFFilename = False
stng.ShouldShowProgressDialog = True
stng.ViewPDFFile = False
pmkr.CreatePDFEx stng, 0 'perform conversion
If Dir(pdfname) = "" Then ' see if conversion failed
MsgBox "Could not create " & pdfname, vbOKOnly, "Conversion failed"
End If
End With
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



"Paul Moloney" <paul_moloney(a)REMOVETHIShotmail.com> wrote in message
news:010AC631-8261-4D00-9607-F5C2D2926970(a)microsoft.com...
> I'm trying to create a macro which does some checks on a document (for
> example, refreshes all fields and checks for broken x-refs by searching
> for the text "Error!") before PDFing it.
>
> Does anyone know what VBA will perform the same task performed by clicking
> the Acrobat-->Create PDF option?
>
> Also, if anyone know of any similar macros that perform error-checking on
> Word document, please let me know,
>
> Thanks,
>
> P.


From: Graham Mayor on
I forgot the error search

Dim oField As Field
For Each oField In ActiveDocument.Fields
If InStr(1, oField.Result, "Error!") Then
oField.Select
MsgBox oField.Code
Exit Sub
End If
Next oField

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



"Paul Moloney" <paul_moloney(a)REMOVETHIShotmail.com> wrote in message
news:010AC631-8261-4D00-9607-F5C2D2926970(a)microsoft.com...
>
> I'm trying to create a macro which does some checks on a document (for
> example, refreshes all fields and checks for broken x-refs by searching
> for the text "Error!") before PDFing it.
>
> Does anyone know what VBA will perform the same task performed by clicking
> the Acrobat-->Create PDF option?
>
> Also, if anyone know of any similar macros that perform error-checking on
> Word document, please let me know,
>
> Thanks,
>
> P.