Hi,
I'm trying to create individual PDF documents from a mail merge in Word.
It's choking on the PrintOut command with the error:
Run-time error '5121':
Word experienced an error when trying to open the file.
Try these suggestions.
* Check the file permissions for the document or drive.
* Make sure there is sufficient free memory and disk space.
* Open the file with the Text Recovery converter.
Any ideas on how to fix? (The drive permissions are correct and there is enough file space.)
I'm trying to create individual PDF documents from a mail merge in Word.
It's choking on the PrintOut command with the error:
Run-time error '5121':
Word experienced an error when trying to open the file.
Try these suggestions.
* Check the file permissions for the document or drive.
* Make sure there is sufficient free memory and disk space.
* Open the file with the Text Recovery converter.
Any ideas on how to fix? (The drive permissions are correct and there is enough file space.)
Code:
Sub PrintToPDF()
Dim i As Long
' i = ActiveDocument.MailMerge.DataSource.RecordCount
i = 5
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdFirstRecord
Do While intCounter < i
intCounter = intCounter + 1
ActivePrinter = "mmpdfprinter"
Application.PrintOut FileName:="Z:\" & _
ActiveDocument.Bookmarks("branch_number").Range.Text & " - " & _
ActiveDocument.Bookmarks("payroll_number").Range.Text & ".pdf"
ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord
Loop
End Sub