Spell Check and Mergefields not working

K

kckay

Using Office 2007.

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

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

I have performed the Ctrl-A, Review-> Set Language and disable the "D
not check spelling or grammar." This does not work, as the Mergefield
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 th
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 therefor
will not run when opened.

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

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

kckay

kckay;495006 said:
Using Office 2007.

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

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

I have performed the Ctrl-A, Review- Set Language and disable the "D
not check spelling or grammar." This does not work, as the Mergefield
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 th
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 therefor
will not run when opened.

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

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


I edited the Normal.dotm template and added the VBA code:

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

This runs against any document that opens and is based on the templat
(or refers to Normal.dotm). This seems to solve my problem with th
Mergefields not having the Spell Check run against them. I do not no
performance considerations, but do not see any drop-off at moment
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top