Put the following code in a standard code module (making it
available to the whole workbook).
'------------- bas module ------------------------
Option Explicit
Declare Function GetSystemMetrics Lib "user32" _
(ByVal nIndex As Long) As Long
Declare Function GetSysColor Lib "user32" _
(ByVal nIndex As Long) As Long
Public Function CreateToolTipLabel(oHostOLE As Object, _
sTTLText As String) As Boolean
Dim oToolTipLbl As OLEObject
Dim oOLE As OLEObject
Const SM_CXSCREEN = 0
Const COLOR_INFOTEXT = 23
Const COLOR_INFOBK = 24
Const COLOR_WINDOWFRAME = 6
Application.ScreenUpdating = False
For Each oOLE In ActiveSheet.OLEObjects
If oOLE.Name = "TTL" Then oOLE.Delete
Next oOLE
'create a label control...
Set oToolTipLbl = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label.1")
'...and format it to look as a ToolTipWindow
With oToolTipLbl
.Top = oHostOLE.Top + oHostOLE.Height - 10
.Left = oHostOLE.Left + oHostOLE.Width - 10
.Object.Caption = sTTLText
.Object.Font.Size = 8
.Object.BackColor = GetSysColor(COLOR_INFOBK)
.Object.BackStyle = 1
.Object.BorderColor = GetSysColor(COLOR_WINDOWFRAME)
.Object.BorderStyle = 1
.Object.ForeColor = GetSysColor(COLOR_INFOTEXT)
.Object.TextAlign = 1
.Object.AutoSize = False
.Width = GetSystemMetrics(SM_CXSCREEN)
.Object.AutoSize = True
.Width = .Width + 2
.Height = .Height + 2
.Name = "TTL"
End With
DoEvents
Application.ScreenUpdating = True
'delete the tooltip window after 5 secs
Application.OnTime Now() + TimeValue("00:00:05"), "DeleteToolTipLabels"
End Function
Public Sub DeleteToolTipLabels()
Dim oToolTipLbl As OLEObject
For Each oToolTipLbl In ActiveSheet.OLEObjects
If oToolTipLbl.Name = "TTL" Then oToolTipLbl.Delete
Next oToolTipLbl
End Sub
'------------end of bas module -------------
Then in the code module for the sheet that has the control, add some
mousedown event code. To get to this module, right-click on the sheet name
tab, and selecw code (or double-click on the sheet name from within the VB
IDE). Here is an example of how to call it, assuming that the textbox
is calle TextBox1
Private Sub TextBox1_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, _
ByVal Y As Single)
Dim oTTL As OLEObject
Dim fTTL As Boolean
For Each oTTL In ActiveSheet.OLEObjects
fTTL = oTTL.Name = "TTL"
Next oTTL
If Not fTTL Then
CreateToolTipLabel TextBox1, "ToolTip Label"
End If
End Sub
--
HTH
Bob
(there's no email, no snail mail, but somewhere should be gmail in my addy)