ID: Q135016
7.00 WINDOWS kbprg kbcode kbtool
The information in this article applies to:
When you use the Caller property in a Visual Basic, Applications Edition, macro from a Microsoft Excel section in a Microsoft Office Binder, the Caller property of the Application object returns a different value than it does when it is used in the stand-alone version of Microsoft Excel 7.0.
The following macro example checks for the existence of a different value and then displays the correct value (the value as it appears in the stand- alone version of Microsoft Excel).
Microsoft provides examples of Visual Basic procedures 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 Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose. Note that a line that is preceded by an apostrophe introduces a comment in the code--comments are provided to explain what the code is doing at a particular point in the procedure. Note also that an underscore character (_) indicates that code continues from one line to the next. You can type lines that contain this character as one logical line or you can divide the lines of code and include the line-continuation character. For more information about Visual Basic for Applications programming style, see the "Programming Style in This Manual" section in the "Document Conventions" section of the "Visual Basic User's Guide."
Sub Caller_Button()
'Sets the variable x equal to the name of the control that is calling the
'macro.
x = Application.Caller
'This shows the invalid return string
MsgBox x(2)
'The next line checks the ASCII character to see if it returns a 1, if it
'does, then Microsoft Excel 7.0 knows that the workbook is in a Binder and
'will return the proper name or number of the toolbar.
If Asc(Mid(x(2), Len(x(2)) - 1, 1)) = 1 Then
MsgBox "Toolbar Name/Num: " & Left(x(2), Len(x(2)) - 2) & Chr(13) _
)& "Button Number: " & x(1)
Else
MsgBox "Toolbar Name or Number " & x(2) & Chr(13) & _
"Button Number " & x(1)
End If
End Sub
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
The Caller property returns a different value when the macro is called from a custom button. When you use the Caller property on a custom button, an array of two elements is returned. The first element is the button number, and the second element is the toolbar name or number on which the custom button is located. In the Microsoft Office 95 Binder, the second element will append a "|0" text string to the second element of the Caller array.
KBCategory: kbprg kbcode kbtool KBSubcategory: xlwin offwin
Additional reference words: 7.00 OFF95 XL7
Keywords : offwin xlwin
Version : 7.00
Platform : WINDOWS
Last Reviewed: March 28, 1997