I have created an OCX in VB.
It works like this:
I have a custom form in my Contacts folder.
In that form I have created a custom page.
Have inserted my OCX in that page.
I now open my form by clicking on one of the entries
in my contacts folder...
Then I click on my custom page tab in that form which
triggers UserControl_Show event for my form in my OCX.
This event runs my menu item creation code and I'm a happy guy.
Menu before my code....
.... Tools Actions Help TestMenu (where TestMenu was inserted
manually)
after my code was triggered
.... Tools Actions Help TestMenu
TestMenuItem (newly created by my code)
So far everything seems nice, however... if I now opens another form
in another folder (this folder is not using my custom made form above)
this form will also show my newly created menuItem.
______ This is my main question ________
Is it possible to create a menuItem which is only visible from the
form, or even better only from the combination form/window that
actually run the code below?
______ End main question _______
Is there perhaps some properties that make this menuItem only visible
from
the window that the menuItem was created in.
Any clean solution to this or perhaps some workaround?
********* THE CODE *******
Private Sub UserControl_Show()
Dim objApp As Outlook.Application
Set objApp = CreateObject("Outlook.Application")
Set colCB = objApp.ActiveInspector.CommandBars
For Each objCB In colCB
'strMainMen = strMainMen & ", " & objCB.Caption
For Each objControl In objCB.Controls
If objControl.Caption = "TestMenu" Then
Set objCBCs = objControl.Controls
Set objCBB = objCBCs.Add
objCBB.Caption = "TestMenuItem"
End If
Next
Next
end sub
******* END THE CODE ******
Tore
|