XL: Macro to Determine If Excel Is Open for In-Place Editing

Last reviewed: December 1, 1997
Article ID: Q110754
The information in this article applies to:
  • Microsoft Excel for Windows, version 5.0
  • Microsoft Excel for the Macintosh, version 5.0
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Excel 97 for Windows

SUMMARY

In Microsoft Excel, there is no Visual Basic function to determine whether Microsoft Excel is open for in-place editing. To return this information in a Visual Basic procedure, you must run a Microsoft Excel 4.0 macro that uses the GET.WORKSPACE() macro function.

MORE INFORMATION

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 engineers 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/support/supportnet/refguide/default.asp

When you embed a Microsoft Excel worksheet or chart in a program that supports in-place activation, when you double-click the embedded object, you remain in the client application but the menus and toolbars change to those of Microsoft Excel. It may be useful in a Visual Basic procedure to determine whether Microsoft Excel is open for in-place editing. For example, you may create an add-in that needs to perform different actions if Microsoft Excel is open for in-place editing.

The GET.WORKSPACE() macro function returns information about the workspace. You can use this function with the following syntax to determine whether Microsoft Excel is open for in-place editing:

   =GET.WORKSPACE(71)

To return this information in a Visual Basic procedure, you can use the RUN method to run a Microsoft Excel version 4.0 macro containing the GET.WORKSPACE(71) function. The following procedure, demonstrates how to use this method.

  1. In a new Microsoft Excel 4.0 macro sheet, enter the following:

          A1:  Inplace_Edit
          A2:  =ALERT(GET.WORKSPACE(71))
          A3:  =RETURN()
    

  2. Select cell A1. On the Insert menu, point to Name, and then click Define.

  3. In the Names In Workbook box, type "Inplace_Edit" (without the quotation marks). In the Refers To box, type "=Macro1!$A$1" (without the quotation marks). Under Macro, select the Command option, and then click OK.

  4. In a new Visual Basic module, type the following:

          Sub Test()
             MsgBox Application.ExecuteExcel4Macro("GET.WORKSPACE(71)")
          End Sub
    
    
When you run the Visual Basic procedure "Test," a message box appears with the value "True" if Microsoft Excel is open for in-place editing, or "False" if Microsoft Excel is open for normal editing.

REFERENCES

For more information about Editing a Microsoft Excel Object Embedded In Another Application, choose the Search button in Help and type:

    in-place activation

For more information about the Run Method, choose the Search button in the Visual Basic Reference and type:

    Run Method


Additional query words: 5.00 ole link embed linking embedding
Keywords : kbcode kbprg
Version : WINDOWS:5.0,7.0,97; MACINTOSH:5.0
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


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: December 1, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.