Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Unable to Run Code on Specific workbook

I got some great help here last night, so I thought I'd try again. I'm
creating a custom menu for a 29 worksheet template. I can run the following
code on new workbooks, but I can run it on the one that I need, the template.

Sub Auto_Open()
Dim HelpIndex As Integer
Dim NewMenu As CommandBarPopup

' Get Index of Help menu
HelpIndex = CommandBars(1).Controls("Help").Index

' Create the control
Set NewMenu = CommandBars(1) _
.Controls.Add(Type:=msoControlPopup, _
Befo=HelpIndex, Temporary:=True)
' Add a caption
NewMenu.Caption = "&Custom Menu"
End Sub

I get the following error:

Compile error:
User-Defined Type Not Defined

And it highlights the following line:

NewMenu As CommandBarPopup

Does anyone have any idea of why it doesn't work on this particluar workbook?
Any comments are appreciated.

Renato

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Unable to Run Code on Specific workbook

Ensure that you have a reference (VBA Tools menu, References) to
"Microsoft Office Object Library" and that no reference is marked
"MISSING".


"Renato" wrote in message
...
I got some great help here last night, so I thought I'd try
again. I'm
creating a custom menu for a 29 worksheet template. I can run
the following
code on new workbooks, but I can run it on the one that I need,
the template.

Sub Auto_Open()
Dim HelpIndex As Integer
Dim NewMenu As CommandBarPopup

' Get Index of Help menu
HelpIndex = CommandBars(1).Controls("Help").Index

' Create the control
Set NewMenu = CommandBars(1) _
.Controls.Add(Type:=msoControlPopup, _
Befo=HelpIndex, Temporary:=True)
' Add a caption
NewMenu.Caption = "&Custom Menu"
End Sub

I get the following error:

Compile error:
User-Defined Type Not Defined

And it highlights the following line:

NewMenu As CommandBarPopup

Does anyone have any idea of why it doesn't work on this
particluar workbook?
Any comments are appreciated.

Renato



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Unable to Run Code on Specific workbook

It looks like the whole references & additional controls menu items are
missing (they appear but are dimmed).
Is there any way to add them back in this workbook?

"Chip Pearson" wrote:

Ensure that you have a reference (VBA Tools menu, References) to
"Microsoft Office Object Library" and that no reference is marked
"MISSING".


"Renato" wrote in message
...
I got some great help here last night, so I thought I'd try
again. I'm
creating a custom menu for a 29 worksheet template. I can run
the following
code on new workbooks, but I can run it on the one that I need,
the template.

Sub Auto_Open()
Dim HelpIndex As Integer
Dim NewMenu As CommandBarPopup

' Get Index of Help menu
HelpIndex = CommandBars(1).Controls("Help").Index

' Create the control
Set NewMenu = CommandBars(1) _
.Controls.Add(Type:=msoControlPopup, _
Befo=HelpIndex, Temporary:=True)
' Add a caption
NewMenu.Caption = "&Custom Menu"
End Sub

I get the following error:

Compile error:
User-Defined Type Not Defined

And it highlights the following line:

NewMenu As CommandBarPopup

Does anyone have any idea of why it doesn't work on this
particluar workbook?
Any comments are appreciated.

Renato




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Unable to Run Code on Specific workbook

I was mistaken in the previous post.
The Microsoft Office Object Library that Chip mentioned, did not have a
check mark next to it. I added the check mark and the code seems to run with
no problems.
Thanks a lot Chip! Great forum with very smart people.
Thanks again!

Renato

"Renato" wrote:

It looks like the whole references & additional controls menu items are
missing (they appear but are dimmed).
Is there any way to add them back in this workbook?

"Chip Pearson" wrote:

Ensure that you have a reference (VBA Tools menu, References) to
"Microsoft Office Object Library" and that no reference is marked
"MISSING".


"Renato" wrote in message
...
I got some great help here last night, so I thought I'd try
again. I'm
creating a custom menu for a 29 worksheet template. I can run
the following
code on new workbooks, but I can run it on the one that I need,
the template.

Sub Auto_Open()
Dim HelpIndex As Integer
Dim NewMenu As CommandBarPopup

' Get Index of Help menu
HelpIndex = CommandBars(1).Controls("Help").Index

' Create the control
Set NewMenu = CommandBars(1) _
.Controls.Add(Type:=msoControlPopup, _
Befo=HelpIndex, Temporary:=True)
' Add a caption
NewMenu.Caption = "&Custom Menu"
End Sub

I get the following error:

Compile error:
User-Defined Type Not Defined

And it highlights the following line:

NewMenu As CommandBarPopup

Does anyone have any idea of why it doesn't work on this
particluar workbook?
Any comments are appreciated.

Renato




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
Unable to sum the specific cells containing both text & values Shafaq Shabieh Excel Worksheet Functions 5 November 4th 08 08:42 AM
Form keep the focus unable to get to the code - HELP! Kaz G New Users to Excel 1 January 23rd 08 06:00 PM
Opens to form then keep focus and unable to get to code - HELP!! Kaz G Excel Discussion (Misc queries) 0 January 23rd 08 01:16 AM
Code for opening a workbook at a specific time!?! mike_vr Excel Discussion (Misc queries) 2 June 5th 07 04:55 PM
unable to filter by specific data on a column if the rows exceed 1 Devarajan Mohan Excel Worksheet Functions 0 December 6th 06 01:47 AM


All times are GMT +1. The time now is 08:38 PM.

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"