subscript out of range

  • Thread starter Thread starter anil kumar a a
  • Start date Start date
A

anil kumar a a

I am getting the error "subscript out of range" while
accessing the commandbar items, the same code works fine
for office 78 / 2000. but it throws the above specified
error after migrating to office XP.

Any help is appreciated

Thanks in advance

Rgds
Anil
 
Hi Sue Mosher,

Thanks for helping out.. Here are the code snippet:

1) Set myMenuItem = Nothing
2) Set myCommandBars = Item.GetInspector.Commandbars
3) Set myMenuItem = myCommandBars(2).Controls(1)

Here the line numbers are jusr for reference. When the the third line
gets executed, it throws the below given error.

"Subscript out of range".

The same code works fine in case of Office 98 and office 2K. I am
getting this problem since i migrated to Office XP and OS - XP.

The above given code is of Outlook forms.

Thankx for your effort and help in advance.





*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
My guess is that myCommandBars(2) is different in different versions, which
is not unexpected. A better way to return a particular control is with the
CommandBars.FindControl method. You'll need to know the control's ID. If you
don't want to write your own code to recurse the Explorer.CommandBars and
Inspector.CommandBars collections, you can use either the CommandBars
Browser or Outlook Spy tools listed at
http://www.slipstick.com/dev/vb.htm#tools

See http://www.outlookcode.com/d/tips/commandbarfun.htm for many examples of
FindControl.
 
Back
Top