Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2024, 05:21 AM
Napier Napier is offline Mail Merge issues - Word crashing and screen still updating Windows 11 Mail Merge issues - Word crashing and screen still updating Office 2021
Novice
Mail Merge issues - Word crashing and screen still updating
 
Join Date: Apr 2024
Posts: 1
Napier is on a distinguished road
Default 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.
  • The screen kept updating. I had intended to stop this but new Word windows kept opening with each individual file.
    I experienced what appears to be the same error described here. This is why I commented out the ".Close SaveChanges:=False" line in the code - otherwise Word would crash. This meant it worked, but due to the large number of files being open my PC slowed down significantly.
    The user in the thread I linked to said they resolved the issue by making the document not a template. This is probably my lack of knowledge, but I didn't understand what was meant by this - could someone assist? To the best of my knowledge I haven't made the document a template.

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
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merge issues - Word crashing and screen still updating Mail merge issues AndreaStringhetti Mail Merge 1 10-31-2018 06:06 PM
Mail Merge issues - Word crashing and screen still updating Updating mail merge data jaydee456 Mail Merge 3 12-23-2016 08:01 PM
Mail Merge issues - Word crashing and screen still updating 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

Other Forums: Access Forums

All times are GMT -7. The time now is 10:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft