Discussion:
How to notify other ActiveX control about custom menu item click in Ms Word using Add-In
(too old to reply)
a***@gmail.com
2005-11-30 06:11:44 UTC
Permalink
Hello Everyone,

I have been working on web based content management system using:

VB 6.0 (Front End)
SQL Server 2000 (Back End)

Our System has 2 main ActiveX controls, which are installed at client
side when accessing the site:

1) Main GUI Control - Working with system
2) Editor - is used to create documents.

We are suppose to customize MS Word according to our requirements so
that it can be used as Editor.

As per the requirements we need to add our custom menu and menu items
into MS Word 2003 standard menu. We have done this using Add-in
project.
(E.g. "Test Menu" which will have 4 sub items - Open, Save, Save
As, Close)

Now we want that when user clicks any of these sub menu items, our Main
GUI control should be notified about this particular click, so that we
can do further processing and update the database accordingly.

Here are some of the details about my Add-in project:

I) I am using Office.CommandBarButton for declaring each click events.
(e.g.Public WithEvents mcmdBarMenuItemSave As Office.CommandBarButton)

I am getting the click event for each of the CommandBars
(e.g. Public Sub mcmdBarMenuItemSave_click)

II) I want to raise events in the main GUI Control for each click
event(s) called.

Or is there any other way for notifying the main GUI control regarding
which particular click event is called?

Any help will be greatly appreciated.

Thanks in advance.

Regards,

Atit
Default User
2005-12-01 23:27:45 UTC
Permalink
You could try to use the ActionControl property under the CommandBars
collection.
It returns the active control.

Debug.Print wd.CommandBars.ActionControl.Name
whereby "wd" is a valid and instantiated object variable pointing to the
appropriate Word application instance.

Krgrds,
Perry
Post by a***@gmail.com
Hello Everyone,
VB 6.0 (Front End)
SQL Server 2000 (Back End)
Our System has 2 main ActiveX controls, which are installed at client
1) Main GUI Control - Working with system
2) Editor - is used to create documents.
We are suppose to customize MS Word according to our requirements so
that it can be used as Editor.
As per the requirements we need to add our custom menu and menu items
into MS Word 2003 standard menu. We have done this using Add-in
project.
(E.g. "Test Menu" which will have 4 sub items - Open, Save, Save
As, Close)
Now we want that when user clicks any of these sub menu items, our Main
GUI control should be notified about this particular click, so that we
can do further processing and update the database accordingly.
I) I am using Office.CommandBarButton for declaring each click events.
(e.g.Public WithEvents mcmdBarMenuItemSave As Office.CommandBarButton)
I am getting the click event for each of the CommandBars
(e.g. Public Sub mcmdBarMenuItemSave_click)
II) I want to raise events in the main GUI Control for each click
event(s) called.
Or is there any other way for notifying the main GUI control regarding
which particular click event is called?
Any help will be greatly appreciated.
Thanks in advance.
Regards,
Atit
a***@gmail.com
2005-12-03 04:20:54 UTC
Permalink
Hi Perry,

Thanks for the reply.

I have tried the code :

Debug.Print wd.CommandBars.ActionControl.Name - in the click event of
one my Menu items like below:

Public Sub mcmdBarMenuItemSave_click(ByVal Ctrl As
Office.CommandBarButton, CancelDefault As Boolean)
Debug.Print oWord.CommandBars.ActionControl.Name
'oWord is the instance variable for Word application
End Sub

but this is code is not running.

I think I have made some mistake in using this in my code. If you could
provide some code snip then it will really helpful.

Secondly, I want these particular Menu click event (e.g. Save Click) to
be notified in my main GUI control (Active X), so please help me out
for this.

Thank you very much again.

Regards,

Atit
Post by Default User
You could try to use the ActionControl property under the CommandBars
collection.
It returns the active control.
Debug.Print wd.CommandBars.ActionControl.Name
whereby "wd" is a valid and instantiated object variable pointing to the
appropriate Word application instance.
Krgrds,
Perry
Post by a***@gmail.com
Hello Everyone,
VB 6.0 (Front End)
SQL Server 2000 (Back End)
Our System has 2 main ActiveX controls, which are installed at client
1) Main GUI Control - Working with system
2) Editor - is used to create documents.
We are suppose to customize MS Word according to our requirements so
that it can be used as Editor.
As per the requirements we need to add our custom menu and menu items
into MS Word 2003 standard menu. We have done this using Add-in
project.
(E.g. "Test Menu" which will have 4 sub items - Open, Save, Save
As, Close)
Now we want that when user clicks any of these sub menu items, our Main
GUI control should be notified about this particular click, so that we
can do further processing and update the database accordingly.
I) I am using Office.CommandBarButton for declaring each click events.
(e.g.Public WithEvents mcmdBarMenuItemSave As Office.CommandBarButton)
I am getting the click event for each of the CommandBars
(e.g. Public Sub mcmdBarMenuItemSave_click)
II) I want to raise events in the main GUI Control for each click
event(s) called.
Or is there any other way for notifying the main GUI control regarding
which particular click event is called?
Any help will be greatly appreciated.
Thanks in advance.
Regards,
Atit
Default User
2005-12-03 17:37:32 UTC
Permalink
Try to run the subroutine without passing parameter, assign that routine
(w/o params) to the clickevent of the menu item and retry.
For all I know, you can't pass a paramatrized routine to the click event of
a commandbar control

Public Sub mcmdBarMenuItemSave_click()
Debug.Print oWord.CommandBars.ActionControl.Name
End Sub

If you utilize the callback properly, you can fire appropriate subroutines
like in below sequence:

Public Sub mcmdBarMenuItemSave_click()
Select Case ActionControl.Name
Case "mBtnSave"
Call mBtn_SaveRoutine
Case "mBtnClose"
Call mBtn_CloseRoutine
...etc
End Select
End Sub

Krgrds,
Perry
Post by a***@gmail.com
Hi Perry,
Thanks for the reply.
Debug.Print wd.CommandBars.ActionControl.Name - in the click event of
Public Sub mcmdBarMenuItemSave_click(ByVal Ctrl As
Office.CommandBarButton, CancelDefault As Boolean)
Debug.Print oWord.CommandBars.ActionControl.Name
'oWord is the instance variable for Word application
End Sub
but this is code is not running.
I think I have made some mistake in using this in my code. If you could
provide some code snip then it will really helpful.
Secondly, I want these particular Menu click event (e.g. Save Click) to
be notified in my main GUI control (Active X), so please help me out
for this.
Thank you very much again.
Regards,
Atit
Post by Default User
You could try to use the ActionControl property under the CommandBars
collection.
It returns the active control.
Debug.Print wd.CommandBars.ActionControl.Name
whereby "wd" is a valid and instantiated object variable pointing to the
appropriate Word application instance.
Krgrds,
Perry
Post by a***@gmail.com
Hello Everyone,
VB 6.0 (Front End)
SQL Server 2000 (Back End)
Our System has 2 main ActiveX controls, which are installed at client
1) Main GUI Control - Working with system
2) Editor - is used to create documents.
We are suppose to customize MS Word according to our requirements so
that it can be used as Editor.
As per the requirements we need to add our custom menu and menu items
into MS Word 2003 standard menu. We have done this using Add-in
project.
(E.g. "Test Menu" which will have 4 sub items - Open, Save, Save
As, Close)
Now we want that when user clicks any of these sub menu items, our Main
GUI control should be notified about this particular click, so that we
can do further processing and update the database accordingly.
I) I am using Office.CommandBarButton for declaring each click events.
(e.g.Public WithEvents mcmdBarMenuItemSave As Office.CommandBarButton)
I am getting the click event for each of the CommandBars
(e.g. Public Sub mcmdBarMenuItemSave_click)
II) I want to raise events in the main GUI Control for each click
event(s) called.
Or is there any other way for notifying the main GUI control regarding
which particular click event is called?
Any help will be greatly appreciated.
Thanks in advance.
Regards,
Atit
a***@gmail.com
2005-12-05 06:02:00 UTC
Permalink
Hi Perry,

Actually I am not getting the .Name property in either Menu Click or in
other events, so I am not able to use this.

Is it because of some references to be add in my project. I have
Microsoft Office 11.0 object library and Microsoft Word 11.0 object
library references are added to my Add-in Project.

Thanking you.

Regards,

Atit
Post by Default User
Try to run the subroutine without passing parameter, assign that routine
(w/o params) to the clickevent of the menu item and retry.
For all I know, you can't pass a paramatrized routine to the click event of
a commandbar control
Public Sub mcmdBarMenuItemSave_click()
Debug.Print oWord.CommandBars.ActionControl.Name
End Sub
If you utilize the callback properly, you can fire appropriate subroutines
Public Sub mcmdBarMenuItemSave_click()
Select Case ActionControl.Name
Case "mBtnSave"
Call mBtn_SaveRoutine
Case "mBtnClose"
Call mBtn_CloseRoutine
...etc
End Select
End Sub
Krgrds,
Perry
Post by a***@gmail.com
Hi Perry,
Thanks for the reply.
Debug.Print wd.CommandBars.ActionControl.Name - in the click event of
Public Sub mcmdBarMenuItemSave_click(ByVal Ctrl As
Office.CommandBarButton, CancelDefault As Boolean)
Debug.Print oWord.CommandBars.ActionControl.Name
'oWord is the instance variable for Word application
End Sub
but this is code is not running.
I think I have made some mistake in using this in my code. If you could
provide some code snip then it will really helpful.
Secondly, I want these particular Menu click event (e.g. Save Click) to
be notified in my main GUI control (Active X), so please help me out
for this.
Thank you very much again.
Regards,
Atit
Post by Default User
You could try to use the ActionControl property under the CommandBars
collection.
It returns the active control.
Debug.Print wd.CommandBars.ActionControl.Name
whereby "wd" is a valid and instantiated object variable pointing to the
appropriate Word application instance.
Krgrds,
Perry
Post by a***@gmail.com
Hello Everyone,
VB 6.0 (Front End)
SQL Server 2000 (Back End)
Our System has 2 main ActiveX controls, which are installed at client
1) Main GUI Control - Working with system
2) Editor - is used to create documents.
We are suppose to customize MS Word according to our requirements so
that it can be used as Editor.
As per the requirements we need to add our custom menu and menu items
into MS Word 2003 standard menu. We have done this using Add-in
project.
(E.g. "Test Menu" which will have 4 sub items - Open, Save, Save
As, Close)
Now we want that when user clicks any of these sub menu items, our Main
GUI control should be notified about this particular click, so that we
can do further processing and update the database accordingly.
I) I am using Office.CommandBarButton for declaring each click events.
(e.g.Public WithEvents mcmdBarMenuItemSave As Office.CommandBarButton)
I am getting the click event for each of the CommandBars
(e.g. Public Sub mcmdBarMenuItemSave_click)
II) I want to raise events in the main GUI Control for each click
event(s) called.
Or is there any other way for notifying the main GUI control regarding
which particular click event is called?
Any help will be greatly appreciated.
Thanks in advance.
Regards,
Atit
Loading...