Step 3: Edit the VB code to close the main report document
At 1. Write the VB code we modified the VB code by commenting out MainDocument.Close SaveChanges:=False
. Before we finalize the report we need to edit the VB code to remove the apostrophe. Once this is done only the mail merge document will display whenever the report is run:
- Open the main report document.
The Security box displays:
- Click Disable Macros.
Only the main report document opens (i.e. the mail merge document is not generated).
- Select Tools>Macro>Visual Basic Editor from the Menu bar.
The Microsoft Visual Basic editor opens.
- Under the Project (Document 1) folder in the left Project pane, double-click ThisDocument to display the Visual Basic code for the mail merge in the right pane:
- Remove the apostrophe (') from before
Main Document.Close SaveChanges :=False
- Select File>Close and Return to Microsoft Word from the Visual Basic editor Menu bar.
- Save the main report document and close MS Word.