Reply
 
Thread Tools Display Modes
  #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?
  #2   Report Post  
kckay kckay is offline
Junior Member
 
Posts: 2
Default

Quote:
Originally Posted by kckay View Post
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?

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 template (or refers to Normal.dotm). This seems to solve my problem with the Mergefields not having the Spell Check run against them. I do not not performance considerations, but do not see any drop-off at moment.
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Spell check not working???? mykco Microsoft Word Help 0 April 27th 10 11:04 AM
Spell Check still not working Confused Microsoft Word Help 7 April 21st 07 10:20 PM
Spell check and mergefields PromisedOyster Mailmerge 0 May 17th 05 05:08 AM
Spell Check Not working Tcordaro Microsoft Word Help 1 March 22nd 05 08:28 PM
SPELL CHECK AND GRAMAR CHECK IS NOT WORKING IN OFFICE 2003......P. digitalpi New Users 1 March 22nd 05 04:44 AM


All times are GMT +1. The time now is 10:10 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"