View Single Post
  #1   Report Post  
kckay kckay is offline
Junior Member
 
Posts: 2
Default Spell Check and Mergefields not working

Using Office 2007.

I have a project to enter data in an Excel workbook and then generate a Word document from the Excel data. This is working wonderfully and is stable.

Unfortunately, I found that the Mergefields in the Word template are exempt from the Spell Check tool within Word.

I have performed the Ctrl-A, Review- Set Language and disable the "Do not check spelling or grammar." This does not work, as the Mergefields are immediately reset to "Do not check spelling or grammar."

I then inserted a bit of VBA code in the template:

Sub Document_Open()
With ActiveDocument.Range
.NoProofing = False
.LanguageID = wdEnglishUS
End With
End Sub

and saved the template as macro-enabled (.dotm).

The code in Excel to generate the document was modified to access the new template and to also save the document as .docm using

FileFormat:=wdFormatXMLDocumentMacroEnabled in the SaveAs statement.

Unfortunately, the VBA does not save to the new document, so therefore will not run when opened.

If I manually enter the VBA code into the document and save it, the code will run the next time the document is opened and Spell Check works as needed.

Question:
1) How do I ensure that the VBA is carried from the .dotm template to the .docm document?