Major menu weirdness

D

David Thielen

Hi;

This is happening on my computer only (thank god). But I want to
figure out what is going on.

1) This is code that has been running for months without being
touched. And it runs fine on every other computer.

2) This occured after I installed the new shim wizard and got the
shims working. However it occurs if I run with or without the shim. So
I don't think it's a shim issue.

3) If I reset the menu toolbar, exit Word, and then start Word - it
builds my menu correctly. No problems.

4) When I look in the debugger at the end of my menu initialization,
the menu I created is correct.

5) I store my copy of the menu objects in global memory so it has not
been thrown away by the garbage collector.

But... If the menu already exists and my code deletes it and builds it
new, it randomly does one of the following thinks:

a) My menu is in the top menu bar for Word - but has nothing in it.

b) My menu is in the top menu bar and it's contents are the contents
of one of the pop-up menus in my menu. In other words it would be like
the Tools menu's content is just the content of Tools | Language or
Tools | Letters and Mailings. I have 4 pop-up menus in my main menu
and it is randomly any one of these 4 pop-up's content set as the main
menu content.

The fact that this is code I haven't touched for awhile AND the fact
that it is randomly different (or no) children of a single
msoControlPopup in my menu makes me think the problem is in Word.

Any ideas?

thanks - dave

My code (I have a class that has the values used to create the menu
and it stores the created menu object):

CommandBar MainMenuBar = GetCommandBar("Menu Bar");

mainMenu[0].OfficeMenu =
MainMenuBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing,
Type.Missing, before, false);
mainMenu[0].OfficeMenu.Caption = mainMenu[0].Caption;
mainMenu[0].OfficeMenu.TooltipText = mainMenu[0].Tooltip;
mainMenu[0].OfficeMenu.Tag = mainMenu[0].Tag;

// build the menu - main and sub-menus
BuildMenu(mainMenu[0]);

private static void BuildMenu(MenuDef parent)
{
foreach (MenuDef menuOn in parent.Children)
{

if (menuOn.Children != null)
{
menuOn.OfficeMenu =
((CommandBarPopup)parent.OfficeMenu).Controls.Add(MsoControlType.msoControlPopup,
Type.Missing, Type.Missing, Type.Missing, false);
menuOn.OfficeMenu.Caption = menuOn.Caption;
menuOn.OfficeMenu.TooltipText =
menuOn.Tooltip;
menuOn.OfficeMenu.Tag = menuOn.Tag;
menuOn.OfficeMenu.BeginGroup =
menuOn.BeginGroup;

BuildMenu(menuOn);
}
else
{
menuOn.OfficeMenu =
((CommandBarPopup)parent.OfficeMenu).Controls.Add(MsoControlType.msoControlButton,
Type.Missing, Type.Missing, Type.Missing, false);
menuOn.OfficeMenu.Caption = menuOn.Caption;
menuOn.OfficeMenu.TooltipText =
menuOn.Tooltip;
menuOn.OfficeMenu.Tag = menuOn.Tag;
menuOn.OfficeMenu.Visible = true;
menuOn.OfficeMenu.BeginGroup =
menuOn.BeginGroup;
if (menuOn.Handler != null)

((CommandBarButton)menuOn.OfficeMenu).Click += menuOn.Handler;
}
}
}

david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

Hi;

Our AddIn runs on Excel & PowerPoint too. It uses the same code to set
up the menu for all 3. The menu setup works perfectly on both. I'm
getting this problem on Word only.

thanks - dave

ps - our actual code to get the CommandBar is:

string mainMenuName = framework.ParentAppType ==
EFramework.PARENT_APP_TYPE.EXCEL ? "Worksheet Menu Bar" : "Menu Bar";
CommandBar MainMenuBar = GetCommandBar(mainMenuName);



Hi;

This is happening on my computer only (thank god). But I want to
figure out what is going on.

1) This is code that has been running for months without being
touched. And it runs fine on every other computer.

2) This occured after I installed the new shim wizard and got the
shims working. However it occurs if I run with or without the shim. So
I don't think it's a shim issue.

3) If I reset the menu toolbar, exit Word, and then start Word - it
builds my menu correctly. No problems.

4) When I look in the debugger at the end of my menu initialization,
the menu I created is correct.

5) I store my copy of the menu objects in global memory so it has not
been thrown away by the garbage collector.

But... If the menu already exists and my code deletes it and builds it
new, it randomly does one of the following thinks:

a) My menu is in the top menu bar for Word - but has nothing in it.

b) My menu is in the top menu bar and it's contents are the contents
of one of the pop-up menus in my menu. In other words it would be like
the Tools menu's content is just the content of Tools | Language or
Tools | Letters and Mailings. I have 4 pop-up menus in my main menu
and it is randomly any one of these 4 pop-up's content set as the main
menu content.

The fact that this is code I haven't touched for awhile AND the fact
that it is randomly different (or no) children of a single
msoControlPopup in my menu makes me think the problem is in Word.

Any ideas?

thanks - dave


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
C

Colbert Zhou [MSFT]

Hello Dave,

As I understand, we first create and build a global variable mainMenu which
maps to the hierarchy of our menu we want to create. Then we pass the
mainMenu variable as parameter to call the recursion BuildMenu function.

Actually, your codes about the BuildMenu() function look very good to me.
So could this problem caused from the creation of the global mainMenu
variable? Could it be possible that the mainMenu is not created correctly?
For some unknown reasons, it is created as empty or with only one tree path.

So my suggestion is after the mainMenu is created, we can write another
recursion function which Debug.Print the whole structure of the mainMenu to
see if it is as expected.

Something like,

Debug.Print(mainMenu[0].Tag);
PrintMenu (mainMenu[0]);

private static void PrintMenu(MenuDef parent)
{
foreach (MenuDef menuOn in parent.Children)
{

if (menuOn.Children != null)
{
Debug.Print(menuOn.Tag);
PrintMenu (menuOn);
}
else
{
Debug.Print(menuOn.Tag);
}
}
}


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 
D

David Thielen

Hi;

I tried this and it all prints out correct. And the menu is correct on
every computer except my home computer. On my work computer it is
correct.

??? - thanks - dave


Hello Dave,

As I understand, we first create and build a global variable mainMenu which
maps to the hierarchy of our menu we want to create. Then we pass the
mainMenu variable as parameter to call the recursion BuildMenu function.

Actually, your codes about the BuildMenu() function look very good to me.
So could this problem caused from the creation of the global mainMenu
variable? Could it be possible that the mainMenu is not created correctly?
For some unknown reasons, it is created as empty or with only one tree path.

So my suggestion is after the mainMenu is created, we can write another
recursion function which Debug.Print the whole structure of the mainMenu to
see if it is as expected.

Something like,

Debug.Print(mainMenu[0].Tag);
PrintMenu (mainMenu[0]);

private static void PrintMenu(MenuDef parent)
{
foreach (MenuDef menuOn in parent.Children)
{

if (menuOn.Children != null)
{
Debug.Print(menuOn.Tag);
PrintMenu (menuOn);
}
else
{
Debug.Print(menuOn.Tag);
}
}
}


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

Hi;

Any further info on what to do here yet?

thanks - dave


Hi;

I tried this and it all prints out correct. And the menu is correct on
every computer except my home computer. On my work computer it is
correct.

??? - thanks - dave


Hello Dave,

As I understand, we first create and build a global variable mainMenu which
maps to the hierarchy of our menu we want to create. Then we pass the
mainMenu variable as parameter to call the recursion BuildMenu function.

Actually, your codes about the BuildMenu() function look very good to me.
So could this problem caused from the creation of the global mainMenu
variable? Could it be possible that the mainMenu is not created correctly?
For some unknown reasons, it is created as empty or with only one tree path.

So my suggestion is after the mainMenu is created, we can write another
recursion function which Debug.Print the whole structure of the mainMenu to
see if it is as expected.

Something like,

Debug.Print(mainMenu[0].Tag);
PrintMenu (mainMenu[0]);

private static void PrintMenu(MenuDef parent)
{
foreach (MenuDef menuOn in parent.Children)
{

if (menuOn.Children != null)
{
Debug.Print(menuOn.Tag);
PrintMenu (menuOn);
}
else
{
Debug.Print(menuOn.Tag);
}
}
}


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
C

Colbert Zhou [MSFT]

Hello Dave,

Since the Add-In works on all other machines except the home one, so maybe
some machine specific scene causes the issue. To me, most likely the
Normal.dotm may be corrupted. So have you tried to delete the Normail.dotm
file to see if it will fix the issue?

In XP, the Normail.dotm exists in
C:\Documents and Settings\Application Data\Microsoft\Templates

In Vista, the Normail.dotm exists in,
C:\Users\<your user name>\AppData\Roaming\Microsoft\Templates

And another possibility is the affection from other unmanaged or managed
Addins. So have you tried to disable all Addins and only loads your one to
see if it fixes the issue.

The third suggestion is renaming the registry key
HKCU\Software\Microsoft\Office\12.0\Word\Options to another name. When Word
starts up the next time, it will create a brand new Options key for use.
Sometimes some incorrect registry values in Options may lead to problems.

Please let me know if this troubleshooting steps can resolve the issue.


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 
D

David Thielen

Deleting normal.* fixed it - thanks!!!!!


Hello Dave,

Since the Add-In works on all other machines except the home one, so maybe
some machine specific scene causes the issue. To me, most likely the
Normal.dotm may be corrupted. So have you tried to delete the Normail.dotm
file to see if it will fix the issue?

In XP, the Normail.dotm exists in
C:\Documents and Settings\Application Data\Microsoft\Templates

In Vista, the Normail.dotm exists in,
C:\Users\<your user name>\AppData\Roaming\Microsoft\Templates

And another possibility is the affection from other unmanaged or managed
Addins. So have you tried to disable all Addins and only loads your one to
see if it fixes the issue.

The third suggestion is renaming the registry key
HKCU\Software\Microsoft\Office\12.0\Word\Options to another name. When Word
starts up the next time, it will create a brand new Options key for use.
Sometimes some incorrect registry values in Options may lead to problems.

Please let me know if this troubleshooting steps can resolve the issue.


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top