LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Row menu Insert control ID changes

I've had a bug in a program for months now. I've finally figured out the
cause and a solution, but am interested if somebody has a better solution.

It concerns the right-click Row popup menu that comes up when entire rows
are selected. It only occurs at Excel startup, generally by opening a file
from Windows Explorer. What happens is that the Insert control on the Row
menu has an ID of 3181 until the Row menu is activated for the first time.
Once it's activated the ID becomes 3183. The solution I found was to add
and then immediately delete a control from the Row menu.

To see this, add this module to a workbook, save it, close Excel and then
open the file from Windows Explorer. In the immediate window you'll see the
two IDs. This assumes that the Insert control is number 5 on the Row menu -
adjust if it's not.

Private Sub Workbook_Activate()
Rows(1).EntireRow.Select
With Application.CommandBars("Row")
Debug.Print .Controls(5).ID
' this is the fix
.Controls.Add
.Controls(.Controls.Count).Delete
Debug.Print .Controls(5).ID
End With
End Sub

The reason this is a problem for me is I'm hooking controls (as described in
Professional Excel Development and Daily Dose of Excel) when a workbook is
opened. If it's the first workbook opened after Excel starts, then 3183 is
nothing, and is not hooked, and the click event for 3183 does not run.

XL 2003 Win XP

I'd appreciate any thoughts.

Doug


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot insert worksheet in exel - not available in insert menu pedro39 Excel Worksheet Functions 1 July 24th 08 12:09 PM
Hide menu bar control Freshman Excel Worksheet Functions 6 October 24th 07 10:51 AM
Why does a menu pop up when I hit control-C? Oregonnews Excel Worksheet Functions 2 April 24th 07 10:48 PM
What is the application control menu rw7402 New Users to Excel 0 October 31st 06 02:52 AM
Obtain value of a control on a shortcut menu quartz[_2_] Excel Programming 1 February 10th 05 07:20 PM


All times are GMT +1. The time now is 07:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"