I am trying to create a COM Add-in for the MS Word and I wrote the following function of which I used to add a CommandBarButton to the "Web" CommandBar in the MS Word. When this function was called during the startup of MS Word in the OnStartupComplete(), the following error message displayed:

http://hk.geocities.com/saratara_me/errmsg.JPG

Could anybody please tell me what the problems could possibly be?

Many thanks to you all!
VB Code:
  1. Public Function AddToCommandBar() As CommandBarButton
  2.  
  3. Dim cbb As CommandBarButton
  4. Dim Cnt As Integer
  5.  
  6. Cnt = Application.CommandBars("Web").Controls.Count
  7.  
  8. Set cbb = Application.CommandBars("Web").Controls.Add(Type:=msoControlButton, Id:=2950, Before:=Cnt + 1)
  9.  
  10. Set AddToCommandBar = cbb
  11.  
  12. End Function