Changing Word Doc's User Settings via OLE in Notes Agent Script

Author: Tripp W Black

Created: 08/10/2001 at 04:36 PM

 

Category:
Notes Developer Tips
LotusScript

All right, so did anyone say "MSWord is too slow because of the background repagination and so on..." . Fine. So just get rid of it.

Here is my suggestion (and it works) :

' Instantiate your MSWord OLE object

Const OLE_OBJECT = "Word.Application"
Set WordObj = CreateObject ( OLE_OBJECT )

' Backup user's settings on MSWord

intUsersCheckSpellingAsYouType = WordObj.Options.CheckSpellingAsYouType
intUsersCheckGrammarAsYouType = WordObj.Options.CheckGrammarAsYouType
intUsersWindowViewType = WordObj.ActiveWindow.View.Type

' Remove MSWord's "slow" options

WordObj.Options.CheckSpellingAsYouType = False
WordObj.Options.CheckGrammarAsYouType = False

' Remove MSWord background repagination too
' (but you'll have to switch to wdNormalView Window type first, which equals to 1 by the way...)

WordObj.ActiveWindow.View.Type = wdNormalView
intUsersPagination = WordObj.Options.Pagination
WordObj.Options.Pagination = False

' OK, now go ahead...

Call WordObj.Documents.Open("MyDoc.doc")
Set WordDoc = WordObj.ActiveDocument

' TypeText your strings and whatever you want...

' At the very end, restore user's settings on MSWord

WordObj.Options.CheckSpellingAsYouType = intUsersCheckSpellingAsYouType
WordObj.Options.CheckGrammarAsYouType = intUsersCheckGrammarAsYouType

WordObj.Options.Pagination = intUsersPagination
WordObj.ActiveWindow.View.Type = intUsersWindowViewType

' And get rid of MSWord (er... I mean "free your memory")

Set WordObj = Nothing


previous page