Macro to Determine If the Active Window Is the Macro Window

ID: Q88853


The information in this article applies to:
  • Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, version 7.0
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1


SUMMARY

When you run a WordBasic macro, it may generate the error message, "Command is unavailable" if the active window is the macro window. This problem occurs because several macro commands are unavailable if the active window is the macro editing window. Use the appropriate macro below to determine if this is the case.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/supportnet/refguide/

Word 2.0, 6.0, 7.0


   Sub MAIN
    x = SelInfo(27)
    If x = - 1 Then MsgBox "Current window is a macro window"
   End Sub 

Word for Windows version 1.x


   Sub MAIN
    If InStr(WindowName$(), ":") <> 0 And \ 
    Mid$(WindowName$(), InStr(WindowName$(), ":") + 1, 1) \ 
    = " " Then MsgBox "Current window is a macro window"
   End Sub 
NOTE: You can include text in the MsgBox command with instructions to close the window if the window is a macro editing window.


MORE INFORMATION

In version 2.0, 6.0, 7.0 of Microsoft Word for Windows, the WordBasic SelInfo function can be used to return information about the current selection. The SelInfo command is not available in versions 1.x of Word for Windows. The above macro for versions 1.x of Word for Windows uses the InStr command to determine if a colon is in the window name in order to determine if a macro window is open.

The syntax for SelInfo() is as follows:


   n = SelInfo(Type) 
Type number 27 returns the value -1 if the selection is in a macro editing window.


REFERENCES

"Using WordBasic," by Microsoft and WexTech Systems, page 277

Additional query words: winword2 selinfo workaround

Keywords : kbmacro kbprg kbdtacode kbmacroexample winword macword word6 word7 word95
Version : MACINTOSH:6.0,6.0.1; WINDOWS:1.0,1.1,1.1a,2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0
Platform : MACINTOSH WINDOWS
Issue type :


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