OLE Automation: Retrieving Word's Dialog Box Settings

Last reviewed: February 6, 1998
Article 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:

   ARTICLE-ID: Q159547
   TITLE     : How to Remove Settings from Word Dialog Boxes


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

Keywords : kbole kbmacro
Version : 6.0 6.0a 6.0c 7.0 7.0a
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 6, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.