I recently posted about an issue with VBA and the ActiveDocument.ApplyQuickStyleSet method. Execution aborted after after that method. Now I’m finding that another method of ActiveDocument is executing and aborting before running additional lines of code. These issues are in two separate templates (Win10/Office 2016) and do not occur in the Win7/Office2010 version.
I use VMWare and have a VM for each client of mine, and a separate VM client for each verison of Windows/Office for that client. The problem with ActiveDocument methods is peculiar to one VM only. I have a backup from several months ago. I gave that a try and there is no similar issue.
The latest issue is with the (stripped down) code below (where I want to merge the current doc with the specified CSV data file, close the original merge doc and active the merge output):
Sub RBMergeActiveDocument() Dim sOutputDoc As String Dim sMailMergeDocName As String sMailMergeDocName = ActiveDocument.FullName With ActiveDocument.MailMerge .OpenDataSource Name:=”c:temprbdata.csv” .Destination = wdSendToNewDocument .SuppressBlankLines = True With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute End With sOutputDoc = ActiveDocument.FullName Documents(sMailMergeDocName).Saved = True Documents(sMailMergeDocName).Close Documents(sOutputDoc).Activate End Sub
The .Execute method runs, but then the code stops. I did a quick repair of Office; no improvement. I then did the more thorough online repair; no improvement. I don’t know what to do next. I’ve done a lot of developing in the environment over the last month, and I have backups of all templates. I hate the thought of going back to the last full backup of the VM because there have been massive updates to Windows which will take the better part of a day to download and install.
I have run the above test code from the normal template, not from a template that has had a lot of editing.
Any suggestions on how to “fix” Word beyond what the two repair options offer? I use Office 365. Thank you.