OLE Automation: Retrieving Word's Dialog Box SettingsLast reviewed: February 6, 1998Article ID: Q105684 |
The information in this article applies to:
SUMMARYUsing OLE Automation, you can retrieve settings from Word's dialog boxes. In the client application, you need to create an object variable to hold the dialog settings and then place the settings into the variable. For example: WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Dim OptionsVar As Object 'defines object variable Set OptionsVar = WordObj.CurValues.ToolsOptionsViewThe second instruction fills the object variable (OptionsVar) with the settings from the Tools Options View dialog. CurValues is the method used to return the current dialog box settings. Once the dialog box settings are stored in the object variable, you can access the individual settings using the following syntax:
DialogObjectVar.DialogBoxSettingNameThe following Visual Basic procedure determines the current setting of ShowAll in the ToolsOptionsView dialog, and toggles the setting:
Sub Command1_Click () Dim WordObj As Object Dim OptionsVar As Object Set WordObj = CreateObject("Word.Basic") Set OptionsVar = WordObj.CurValues.ToolsOptionsView If OptionsVar.ShowAll = 1 Then WordObj.ToolsOptionsView ,,,,,,,,,,,,,,, 0 Else WordObj.ToolsOptionsView ,,,,,,,,,,,,,,, 1 End If End SubNOTE: Visual Basic version 3.0 does not support named parameters, so you must identify WordBasic arguments by position using commas as placeholders. The above Visual Basic procedure has the same functionality as the following WordBasic macro:
Sub MAIN Dim dlg As ToolsOptionsView GetCurValues dlg If dlg.ShowAll = 1 Then dlg.ShowAll = 0 Else dlg.ShowAll = 1 End If ToolsOptionsView dlg End SubFor information about how to do this in Word 97, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q159547 TITLE : How to Remove Settings from Word Dialog Boxes |
KBCategory: kbmacro
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |