Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Run Time Error 91 in Thisworkbook

Hi Chip. Orginally the post used arrIdNum = Array(295, 296, 945). However
there wa a follow-up note stating:

"Just a note for anyone else who sees Tom's very useful code here. I think
the line:
arrIdNum = Array(295, 296, 945)
should be replaced with:
arrIdNum = Array(295, 296, 3183)
I believe that the 945 control is that to insert a new sheet, where 3183 is
the control to insert a row from the right click menu. "

Thanks

EM

"Chip Pearson" wrote:

From your code, it looks like you need

arrIdNum = Array(295, 296, 945)

I can't find a control with an ID equal to 3183. What control are you
trying to access.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Fri, 3 Apr 2009 15:29:01 -0700, ExcelMonkey
wrote:

I am trying to get this code to work in Excel 2007 as per
http://www.mrexcel.com/forum/showthread.php?t=80626

I have placed it in Thisworkbook module. It is failing on the line:
Set CtrlCbcRet = CommandBars.FindControls(ID:=arrIdNum(lngId))

It is giving me a Run Time Error 91

Why is this?

Private Sub Workbook_Open()
EventHack
End Sub

Sub EventHack()
AssignMacro "JudgeRng"
End Sub

Private Sub AssignMacro(ByVal strProc As String)
Dim lngId As Long
Dim CtrlCbc As CommandBarControl
Dim CtrlCbcRet As CommandBarControls
Dim arrIdNum As Variant

' 295 Insert Cells from worksheet menu
' 296 Insert rows from worksheet menu
' 945 Insert from right click menu

arrIdNum = Array(295, 296, 3183)
For lngId = LBound(arrIdNum) To UBound(arrIdNum)
Set CtrlCbcRet = CommandBars.FindControls(ID:=arrIdNum(lngId))
For Each CtrlCbc In CtrlCbcRet
CtrlCbc.OnAction = strProc
Next
Set CtrlCbcRet = Nothing
Next
End Sub


Reply
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
compile error in hidden module: thisworkbook Tran Thu Do Excel Discussion (Misc queries) 3 June 4th 12 10:33 AM
Compile error in hidden module: ThisWorkbook Slibert New Users to Excel 2 May 19th 08 12:22 AM
Compile error in hidden module: ThisWorkbook Graeme Setting up and Configuration of Excel 3 April 4th 08 03:33 AM
Compile error in hidden module: ThisWorkbook Peo Sjoblom Excel Discussion (Misc queries) 0 May 27th 05 09:50 PM


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

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

About Us

"It's about Microsoft Excel"