OLE Automation: Retrieving Word's Dialog Box Settings

ID: Q105684


The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a


SUMMARY

Using 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.ToolsOptionsView 
The 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.DialogBoxSettingName 
The 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 Sub 
NOTE: 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 Sub 
For information about how to do this in Word 97, please see the following article in the Microsoft Knowledge Base:
Q159547 How to Remove Settings from Word Dialog Boxes

Additional query words: 6.0 ole automation word basic word6 7.0 word95 word7 winword object visual curvalues dlg as dim

Keywords : kbole
Version : WINDOWS:6.0,6.0a,6.0c,7.0,7.0a
Platform : WINDOWS
Issue type :


Last Reviewed: October 18, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.