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

ID: Q110754

The information in this article applies to:

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 can run a Microsoft Excel 4.0 macro that uses the GET.WORKSPACE() macro function.

In Microsoft Excel 97, you can run the following line of code to determine if Microsoft Excel is open for in-place editing:

      MsgBox ActiveWorkbook.IsInplace

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 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/support/supportnet/refguide/

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          : kbprg kbdta kbdtacode KbVBA 
Version           : WINDOWS:5.0,7.0,97; MACINTOSH:5.0
Platform          : MACINTOSH WINDOWS
Issue type        : kbhowto

Last Reviewed: May 17, 1999