#1
|
|||
|
|||
Mail Merge issues - Word crashing and screen still updating
Hi There
This is my first post on the forum, so apologies if the format isn't quite right. I modified the "Send Mailmerge Output to Individual Files" code kindly posted here so suit my needs. I was able to complete my task, but had a few annoying niggles.
Thanks so much for your help! I've pasted my code below. Code:
Sub AutoMerge() Application.ScreenUpdating = False Application.DisplayAlerts = False Dim StrFolder As String, StrName As String, MainDoc As Document, i As Long, j As Long Set MainDoc = ActiveDocument StrFolder = Path & "\" With ActiveDocument.MailMerge .Destination = wdSendToNewDocument .SuppressBlankLines = True For i = 1 To 10 With .DataSource .FirstRecord = i .LastRecord = i .ActiveRecord = i StrName = "C:\Users\X\Documents\" & .DataFields("Name") End With If ShouldWeSave = 1 Then .Execute Pause:=False Application.ScreenUpdating = False ActiveDocument.SaveAs2 FileName:=StrName & ".docx", FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _ AddToRecentFiles:=False, WritePassword:="", ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _ :=False, SaveAsAOCELetter:=False, CompatibilityMode:=15 ActiveDocument.ExportAsFixedFormat OutputFileName:= _ StrName & ".pdf" _ , ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _ wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _ Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _ CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _ BitmapMissingFonts:=True, UseISO19005_1:=False '.Close SaveChanges:=False End If NextRecord: Next i End With Application.ScreenUpdating = True Application.DisplayAlerts = True End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mail merge issues | AndreaStringhetti | Mail Merge | 1 | 10-31-2018 06:06 PM |
Updating mail merge data | jaydee456 | Mail Merge | 3 | 12-23-2016 08:01 PM |
Labels are not printed the way they are shown on the screen! (Word 2013 via Mail Merge) | malinneedshelp | Mail Merge | 2 | 12-09-2014 03:08 AM |
Publisher 2013 Mail Merge Issues | josheridan | Publisher | 0 | 10-23-2014 07:21 AM |
Directory Mail Merge Issues | dbpros_crm | Mail Merge | 10 | 01-20-2014 11:05 PM |