Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default User defined menu stops working when workbook saved with a newname???

Hi all,

I have created my own menu for an Excel workbook using VBA set to run
when the Workbook is opened.

All the menu's work ok and call the correct macros until I save the
Workbook using a new name (workbook2.xls instead of workbook1.xls).
After I've done this, when selecting a menu item Excel displays and
error message saying that it cannot locate the original workbook
(workbook1.xls) and gives me no options to update a link.

All the macros are saved in the new workbook (woorkbook2.xls)

Does anybody know why this is happening??

Thanks in advance for your time,

A
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default User defined menu stops working when workbook saved with a new name???


What is the code you use to assign macros to the menu items?
What version of Excel are you using?
--
Jim Cone
Portland, Oregon USA



"alan82"
wrote in message
Hi all,
I have created my own menu for an Excel workbook using VBA set to run
when the Workbook is opened.
All the menu's work ok and call the correct macros until I save the
Workbook using a new name (workbook2.xls instead of workbook1.xls).
After I've done this, when selecting a menu item Excel displays and
error message saying that it cannot locate the original workbook
(workbook1.xls) and gives me no options to update a link.
All the macros are saved in the new workbook (woorkbook2.xls)
Does anybody know why this is happening??
Thanks in advance for your time,
A
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default User defined menu stops working when workbook saved with a new nam

You probably put a reference into the workbook that included the file name in
the original workbook. Eliminate all the reference that include workbook
like [book1.xls]sheet1!A1:B10. Instead just use sheet1!A1:B10

Try the following to shep solve the problem
1) Do a FIND (worksheet menu Edit find) for the workbookname on all the
worksheets.
2) Look at names (worksheet menu Insert - Name - Define) and look for any
refernces that include the workbook.
3) Check for additional reference in worksheet menu File - Proerties - Custom.

You may need to fix your macro(s) so they don't create references to the
workbook.
"alan82" wrote:

Hi all,

I have created my own menu for an Excel workbook using VBA set to run
when the Workbook is opened.

All the menu's work ok and call the correct macros until I save the
Workbook using a new name (workbook2.xls instead of workbook1.xls).
After I've done this, when selecting a menu item Excel displays and
error message saying that it cannot locate the original workbook
(workbook1.xls) and gives me no options to update a link.

All the macros are saved in the new workbook (woorkbook2.xls)

Does anybody know why this is happening??

Thanks in advance for your time,

A

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default User defined menu stops working when workbook saved with a newname???

On 19 Mar, 16:06, "Jim Cone" wrote:
What is the code you use to assign macros to the menu items?
What version of Excel are you using?
--
Jim Cone
Portland, Oregon *USA

"alan82"
wrote in message
Hi all,
I have created my own menu for an Excel workbook using VBA set to run
when the Workbook is opened.
All the menu's work ok and call the correct macros until I save the
Workbook using a new name (workbook2.xls instead of workbook1.xls).
After I've done this, when selecting a menu item Excel displays and
error message saying that it cannot locate the original workbook
(workbook1.xls) and gives me no options to update a link.
All the macros are saved in the new workbook (woorkbook2.xls)
Does anybody know why this is happening??
Thanks in advance for your time,
A


Excel 2003 SP3

Code:

Sub AddMenus()

Dim cMenu1 As CommandBarControl
Dim cbMainMenuBar As CommandBar
Dim iHelpMenu As Integer
Dim cbcCutomMenu As CommandBarControl

On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("BM
TP").Delete
On Error GoTo 0

Set cbMainMenuBar = Application.CommandBars("Worksheet Menu Bar")
iHelpMenu = cbMainMenuBar.Controls("Help").Index

Set cbcCutomMenu = cbMainMenuBar.Controls.Add(Type:=msoControlPopup,
Befo=iHelpMenu)
cbcCutomMenu.Caption = "BM TP"

With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Populate"
.OnAction = "Populate"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Archive"
.OnAction = "Archive"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Hide Rows"
.OnAction = "HideRows"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Unhide Rows"
.OnAction = "UnhideRows"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Add Headers"
.OnAction = "AddHeaders"
End With

End Sub

Thanks,
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default User defined menu stops working when workbook saved with a new name???


Change the .OnAction code lines to this structure...
.OnAction = ThisWorkbook.Name & "!Populate"
--
Jim Cone
Portland, Oregon USA




"alan82" wrote in message ...
On 19 Mar, 16:06, "Jim Cone" wrote:
What is the code you use to assign macros to the menu items?
What version of Excel are you using?
--
Jim Cone
Portland, Oregon USA

"alan82"
wrote in message
Hi all,
I have created my own menu for an Excel workbook using VBA set to run
when the Workbook is opened.
All the menu's work ok and call the correct macros until I save the
Workbook using a new name (workbook2.xls instead of workbook1.xls).
After I've done this, when selecting a menu item Excel displays and
error message saying that it cannot locate the original workbook
(workbook1.xls) and gives me no options to update a link.
All the macros are saved in the new workbook (woorkbook2.xls)
Does anybody know why this is happening??
Thanks in advance for your time,
A


Excel 2003 SP3

Code:

Sub AddMenus()

Dim cMenu1 As CommandBarControl
Dim cbMainMenuBar As CommandBar
Dim iHelpMenu As Integer
Dim cbcCutomMenu As CommandBarControl

On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("BM
TP").Delete
On Error GoTo 0

Set cbMainMenuBar = Application.CommandBars("Worksheet Menu Bar")
iHelpMenu = cbMainMenuBar.Controls("Help").Index

Set cbcCutomMenu = cbMainMenuBar.Controls.Add(Type:=msoControlPopup,
Befo=iHelpMenu)
cbcCutomMenu.Caption = "BM TP"

With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Populate"
.OnAction = "Populate"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Archive"
.OnAction = "Archive"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Hide Rows"
.OnAction = "HideRows"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Unhide Rows"
.OnAction = "UnhideRows"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Add Headers"
.OnAction = "AddHeaders"
End With

End Sub

Thanks,
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
Can you do user defined Menu Macros in Excel like in Lotus? rcampling Excel Programming 1 December 30th 08 07:28 PM
How to call user defined function (UDF) from custom menu in Excel2003? Dutch_Guy Excel Programming 3 February 28th 08 03:59 PM
After sharing workbook VB code stops working. Runtime Error 1004 Patrick LaFerriere Excel Programming 0 October 5th 05 04:01 PM
User defined menu Glen Mettler[_4_] Excel Programming 2 November 24th 04 07:43 PM
User-Defined function not working Guy Gagnon Excel Programming 3 July 14th 03 03:26 AM


All times are GMT +1. The time now is 01:18 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"