Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Add-In Keyboard Shortcut

i am using an add-in to store macro's ("personal.xla" in C:\Documents and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I need to have a
keyboard shortcut to one fuction within this add-in. The macro list (Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Add-In Keyboard Shortcut

Application.OnKey "+^D", "MyMacro"

This should create a shortcut Shift-Ctrl-D. If there's any possibility
MyMacro may exist in any other workbook prefix with ThisWorkbook.Name & "!".
Call it from an Open event.

Not sure about naming your addin "Personal.xla" if there may also be a
Personal.xls open, guess it's OK but I wouldn't.

Regards,
Peter T

"mvyvoda" wrote in message
...
i am using an add-in to store macro's ("personal.xla" in C:\Documents and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I need to have a
keyboard shortcut to one fuction within this add-in. The macro list

(Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Add-In Keyboard Shortcut

Peter,

When I do this, and get rid of the menu already in place (but run your code)
I get an error:

The macro" C:\..\AddIns\personal.xla'!AddMenu' cannot be found

do you what this means?

Thanks,
-m

"Peter T" wrote:

Application.OnKey "+^D", "MyMacro"

This should create a shortcut Shift-Ctrl-D. If there's any possibility
MyMacro may exist in any other workbook prefix with ThisWorkbook.Name & "!".
Call it from an Open event.

Not sure about naming your addin "Personal.xla" if there may also be a
Personal.xls open, guess it's OK but I wouldn't.

Regards,
Peter T

"mvyvoda" wrote in message
...
i am using an add-in to store macro's ("personal.xla" in C:\Documents and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I need to have a
keyboard shortcut to one fuction within this add-in. The macro list

(Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Add-In Keyboard Shortcut

Why do you "get rid of the menu already in place"

Is AddMenu a Sub with no arguments

Do you have a similarly named AddMenu sub in any other workbook (incl
addins), if so did you prefix the way I suggested.

Apart from your Personal.xla do you also have Personal.xls, if so try
renaming the addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
Peter,

When I do this, and get rid of the menu already in place (but run your

code)
I get an error:

The macro" C:\..\AddIns\personal.xla'!AddMenu' cannot be found

do you what this means?

Thanks,
-m

"Peter T" wrote:

Application.OnKey "+^D", "MyMacro"

This should create a shortcut Shift-Ctrl-D. If there's any possibility
MyMacro may exist in any other workbook prefix with ThisWorkbook.Name &

"!".
Call it from an Open event.

Not sure about naming your addin "Personal.xla" if there may also be a
Personal.xls open, guess it's OK but I wouldn't.

Regards,
Peter T

"mvyvoda" wrote in message
...
i am using an add-in to store macro's ("personal.xla" in C:\Documents

and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I need to have a
keyboard shortcut to one fuction within this add-in. The macro list

(Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Add-In Keyboard Shortcut

I got rid of the menu already in place to test to see if the ctrl+shift+D
would work if only personal.xla was in place and never ran. also, i did
rename the file, to no avail.

I don't have any other macro's that are similarly named.

AddMenu is a pretty typical routine that merely adds a menu, names it and
places arguments (attached to macros of course) within the menu.

Peter, I really appreciate all your help!!,
-m

"Peter T" wrote:

Why do you "get rid of the menu already in place"

Is AddMenu a Sub with no arguments

Do you have a similarly named AddMenu sub in any other workbook (incl
addins), if so did you prefix the way I suggested.

Apart from your Personal.xla do you also have Personal.xls, if so try
renaming the addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
Peter,

When I do this, and get rid of the menu already in place (but run your

code)
I get an error:

The macro" C:\..\AddIns\personal.xla'!AddMenu' cannot be found

do you what this means?

Thanks,
-m

"Peter T" wrote:

Application.OnKey "+^D", "MyMacro"

This should create a shortcut Shift-Ctrl-D. If there's any possibility
MyMacro may exist in any other workbook prefix with ThisWorkbook.Name &

"!".
Call it from an Open event.

Not sure about naming your addin "Personal.xla" if there may also be a
Personal.xls open, guess it's OK but I wouldn't.

Regards,
Peter T

"mvyvoda" wrote in message
...
i am using an add-in to store macro's ("personal.xla" in C:\Documents

and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I need to have a
keyboard shortcut to one fuction within this add-in. The macro list
(Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Add-In Keyboard Shortcut

oh... I misnamed AddMenu. It works now, however I have a final question. I
have a scenario whereby I need this ctrl+shift+D to work in a situation where
someone has never ran the AddMenu routine. Is this possible? Or, do I have to
run AddMenu with the added ctrl+shift+D code before they can use ctrl+shift+D?

If you follow?

Thanks,
-m

"mvyvoda" wrote:

I got rid of the menu already in place to test to see if the ctrl+shift+D
would work if only personal.xla was in place and never ran. also, i did
rename the file, to no avail.

I don't have any other macro's that are similarly named.

AddMenu is a pretty typical routine that merely adds a menu, names it and
places arguments (attached to macros of course) within the menu.

Peter, I really appreciate all your help!!,
-m

"Peter T" wrote:

Why do you "get rid of the menu already in place"

Is AddMenu a Sub with no arguments

Do you have a similarly named AddMenu sub in any other workbook (incl
addins), if so did you prefix the way I suggested.

Apart from your Personal.xla do you also have Personal.xls, if so try
renaming the addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
Peter,

When I do this, and get rid of the menu already in place (but run your

code)
I get an error:

The macro" C:\..\AddIns\personal.xla'!AddMenu' cannot be found

do you what this means?

Thanks,
-m

"Peter T" wrote:

Application.OnKey "+^D", "MyMacro"

This should create a shortcut Shift-Ctrl-D. If there's any possibility
MyMacro may exist in any other workbook prefix with ThisWorkbook.Name &

"!".
Call it from an Open event.

Not sure about naming your addin "Personal.xla" if there may also be a
Personal.xls open, guess it's OK but I wouldn't.

Regards,
Peter T

"mvyvoda" wrote in message
...
i am using an add-in to store macro's ("personal.xla" in C:\Documents

and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I need to have a
keyboard shortcut to one fuction within this add-in. The macro list
(Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Add-In Keyboard Shortcut

I'm glad you've got it working but not sure I understand your follow-up
question.

You need to run the code that assigns the shortcut to your AddMenu proc,
typically from an open event which might also add a menu. There's no need
for the proc to have run once before it will work from the shortcut.

It's unusual to have a shortcut that runs code to add menu items, at least I
assume that's what AddMenu does. More conventional would be to have both the
OnAction property of a menu item and your shortcut linked to a procedure
that starts some functional aspect of your addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
oh... I misnamed AddMenu. It works now, however I have a final question. I
have a scenario whereby I need this ctrl+shift+D to work in a situation

where
someone has never ran the AddMenu routine. Is this possible? Or, do I have

to
run AddMenu with the added ctrl+shift+D code before they can use

ctrl+shift+D?

If you follow?

Thanks,
-m

"mvyvoda" wrote:

I got rid of the menu already in place to test to see if the

ctrl+shift+D
would work if only personal.xla was in place and never ran. also, i did
rename the file, to no avail.

I don't have any other macro's that are similarly named.

AddMenu is a pretty typical routine that merely adds a menu, names it

and
places arguments (attached to macros of course) within the menu.

Peter, I really appreciate all your help!!,
-m

"Peter T" wrote:

Why do you "get rid of the menu already in place"

Is AddMenu a Sub with no arguments

Do you have a similarly named AddMenu sub in any other workbook (incl
addins), if so did you prefix the way I suggested.

Apart from your Personal.xla do you also have Personal.xls, if so try
renaming the addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
Peter,

When I do this, and get rid of the menu already in place (but run

your
code)
I get an error:

The macro" C:\..\AddIns\personal.xla'!AddMenu' cannot be found

do you what this means?

Thanks,
-m

"Peter T" wrote:

Application.OnKey "+^D", "MyMacro"

This should create a shortcut Shift-Ctrl-D. If there's any

possibility
MyMacro may exist in any other workbook prefix with

ThisWorkbook.Name &
"!".
Call it from an Open event.

Not sure about naming your addin "Personal.xla" if there may also

be a
Personal.xls open, guess it's OK but I wouldn't.

Regards,
Peter T

"mvyvoda" wrote in message
...
i am using an add-in to store macro's ("personal.xla" in

C:\Documents
and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I need to

have a
keyboard shortcut to one fuction within this add-in. The macro

list
(Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Add-In Keyboard Shortcut

From the users standpoint, I have a series of macro's that can only run from
a menu (as opposed to going into the code and running the macro). However,
each iteration of my .xla file (which stores the macro's) I change this menu.

So, I want to be able to automatically (via ctrl+shift+d sounds great!) to
change their pre-existing menu to the current one i worked on.

you say it's unconventional to have an entire module dedicated to adding a
menu (AddMenu). You also say you think it wise to add a menu from within
another module. Is that what you're saying? I'm not sure if I follow... this
line of thinking.

I also think i'm in way over my head :-/ But, it's pretty close....

thanks a lot for your time and effort!!!!,
-m

"Peter T" wrote:

I'm glad you've got it working but not sure I understand your follow-up
question.

You need to run the code that assigns the shortcut to your AddMenu proc,
typically from an open event which might also add a menu. There's no need
for the proc to have run once before it will work from the shortcut.

It's unusual to have a shortcut that runs code to add menu items, at least I
assume that's what AddMenu does. More conventional would be to have both the
OnAction property of a menu item and your shortcut linked to a procedure
that starts some functional aspect of your addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
oh... I misnamed AddMenu. It works now, however I have a final question. I
have a scenario whereby I need this ctrl+shift+D to work in a situation

where
someone has never ran the AddMenu routine. Is this possible? Or, do I have

to
run AddMenu with the added ctrl+shift+D code before they can use

ctrl+shift+D?

If you follow?

Thanks,
-m

"mvyvoda" wrote:

I got rid of the menu already in place to test to see if the

ctrl+shift+D
would work if only personal.xla was in place and never ran. also, i did
rename the file, to no avail.

I don't have any other macro's that are similarly named.

AddMenu is a pretty typical routine that merely adds a menu, names it

and
places arguments (attached to macros of course) within the menu.

Peter, I really appreciate all your help!!,
-m

"Peter T" wrote:

Why do you "get rid of the menu already in place"

Is AddMenu a Sub with no arguments

Do you have a similarly named AddMenu sub in any other workbook (incl
addins), if so did you prefix the way I suggested.

Apart from your Personal.xla do you also have Personal.xls, if so try
renaming the addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
Peter,

When I do this, and get rid of the menu already in place (but run

your
code)
I get an error:

The macro" C:\..\AddIns\personal.xla'!AddMenu' cannot be found

do you what this means?

Thanks,
-m

"Peter T" wrote:

Application.OnKey "+^D", "MyMacro"

This should create a shortcut Shift-Ctrl-D. If there's any

possibility
MyMacro may exist in any other workbook prefix with

ThisWorkbook.Name &
"!".
Call it from an Open event.

Not sure about naming your addin "Personal.xla" if there may also

be a
Personal.xls open, guess it's OK but I wouldn't.

Regards,
Peter T

"mvyvoda" wrote in message
...
i am using an add-in to store macro's ("personal.xla" in

C:\Documents
and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I need to

have a
keyboard shortcut to one fuction within this add-in. The macro

list
(Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m









  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Add-In Keyboard Shortcut

you say it's unconventional to have an entire module dedicated to adding a
menu (AddMenu).


No I didn't mean that (an entire module etc). I meant unusual to have a
shortcut to a procedure that in turn adds menu item(s), though I think I now
understand what you are doing.

I would suggest a different approach, and I'm assuming you are not deleting
the menus in the close event. In the tag property of your menus write
something that identifies your xla version, an id. In the open event try
setting a reference to your menus (under On Error Resume Next). If the id
refers to an old version delete it and create new menu(s). Also of course if
the menu doesn't exist create the menu.

Regards,
Peter T

"mvyvoda" wrote in message
...
From the users standpoint, I have a series of macro's that can only run

from
a menu (as opposed to going into the code and running the macro). However,
each iteration of my .xla file (which stores the macro's) I change this

menu.

So, I want to be able to automatically (via ctrl+shift+d sounds great!) to
change their pre-existing menu to the current one i worked on.

you say it's unconventional to have an entire module dedicated to adding a
menu (AddMenu). You also say you think it wise to add a menu from within
another module. Is that what you're saying? I'm not sure if I follow...

this
line of thinking.

I also think i'm in way over my head :-/ But, it's pretty close....

thanks a lot for your time and effort!!!!,
-m

"Peter T" wrote:

I'm glad you've got it working but not sure I understand your follow-up
question.

You need to run the code that assigns the shortcut to your AddMenu proc,
typically from an open event which might also add a menu. There's no

need
for the proc to have run once before it will work from the shortcut.

It's unusual to have a shortcut that runs code to add menu items, at

least I
assume that's what AddMenu does. More conventional would be to have both

the
OnAction property of a menu item and your shortcut linked to a procedure
that starts some functional aspect of your addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
oh... I misnamed AddMenu. It works now, however I have a final

question. I
have a scenario whereby I need this ctrl+shift+D to work in a

situation
where
someone has never ran the AddMenu routine. Is this possible? Or, do I

have
to
run AddMenu with the added ctrl+shift+D code before they can use

ctrl+shift+D?

If you follow?

Thanks,
-m

"mvyvoda" wrote:

I got rid of the menu already in place to test to see if the

ctrl+shift+D
would work if only personal.xla was in place and never ran. also, i

did
rename the file, to no avail.

I don't have any other macro's that are similarly named.

AddMenu is a pretty typical routine that merely adds a menu, names

it
and
places arguments (attached to macros of course) within the menu.

Peter, I really appreciate all your help!!,
-m

"Peter T" wrote:

Why do you "get rid of the menu already in place"

Is AddMenu a Sub with no arguments

Do you have a similarly named AddMenu sub in any other workbook

(incl
addins), if so did you prefix the way I suggested.

Apart from your Personal.xla do you also have Personal.xls, if so

try
renaming the addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
Peter,

When I do this, and get rid of the menu already in place (but

run
your
code)
I get an error:

The macro" C:\..\AddIns\personal.xla'!AddMenu' cannot be found

do you what this means?

Thanks,
-m

"Peter T" wrote:

Application.OnKey "+^D", "MyMacro"

This should create a shortcut Shift-Ctrl-D. If there's any

possibility
MyMacro may exist in any other workbook prefix with

ThisWorkbook.Name &
"!".
Call it from an Open event.

Not sure about naming your addin "Personal.xla" if there may

also
be a
Personal.xls open, guess it's OK but I wouldn't.

Regards,
Peter T

"mvyvoda" wrote in message
...
i am using an add-in to store macro's ("personal.xla" in

C:\Documents
and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I need

to
have a
keyboard shortcut to one fuction within this add-in. The

macro
list
(Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m











  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Add-In Keyboard Shortcut

Peter T,

Haha, sounds like you have a better understanding of this menu dilemma than
I do. I'm afraid I would struggle for days trying to understand the
complexity of your answer. closed events vs. open, tag properties, etc. i
have an unfortunately long-ish AddMenu module. What are the chances of you
taking a peek at it? Is that asking too much of youru time and energy?

Thanks,
Mark

"Peter T" wrote:

you say it's unconventional to have an entire module dedicated to adding a
menu (AddMenu).


No I didn't mean that (an entire module etc). I meant unusual to have a
shortcut to a procedure that in turn adds menu item(s), though I think I now
understand what you are doing.

I would suggest a different approach, and I'm assuming you are not deleting
the menus in the close event. In the tag property of your menus write
something that identifies your xla version, an id. In the open event try
setting a reference to your menus (under On Error Resume Next). If the id
refers to an old version delete it and create new menu(s). Also of course if
the menu doesn't exist create the menu.

Regards,
Peter T

"mvyvoda" wrote in message
...
From the users standpoint, I have a series of macro's that can only run

from
a menu (as opposed to going into the code and running the macro). However,
each iteration of my .xla file (which stores the macro's) I change this

menu.

So, I want to be able to automatically (via ctrl+shift+d sounds great!) to
change their pre-existing menu to the current one i worked on.

you say it's unconventional to have an entire module dedicated to adding a
menu (AddMenu). You also say you think it wise to add a menu from within
another module. Is that what you're saying? I'm not sure if I follow...

this
line of thinking.

I also think i'm in way over my head :-/ But, it's pretty close....

thanks a lot for your time and effort!!!!,
-m

"Peter T" wrote:

I'm glad you've got it working but not sure I understand your follow-up
question.

You need to run the code that assigns the shortcut to your AddMenu proc,
typically from an open event which might also add a menu. There's no

need
for the proc to have run once before it will work from the shortcut.

It's unusual to have a shortcut that runs code to add menu items, at

least I
assume that's what AddMenu does. More conventional would be to have both

the
OnAction property of a menu item and your shortcut linked to a procedure
that starts some functional aspect of your addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
oh... I misnamed AddMenu. It works now, however I have a final

question. I
have a scenario whereby I need this ctrl+shift+D to work in a

situation
where
someone has never ran the AddMenu routine. Is this possible? Or, do I

have
to
run AddMenu with the added ctrl+shift+D code before they can use
ctrl+shift+D?

If you follow?

Thanks,
-m

"mvyvoda" wrote:

I got rid of the menu already in place to test to see if the
ctrl+shift+D
would work if only personal.xla was in place and never ran. also, i

did
rename the file, to no avail.

I don't have any other macro's that are similarly named.

AddMenu is a pretty typical routine that merely adds a menu, names

it
and
places arguments (attached to macros of course) within the menu.

Peter, I really appreciate all your help!!,
-m

"Peter T" wrote:

Why do you "get rid of the menu already in place"

Is AddMenu a Sub with no arguments

Do you have a similarly named AddMenu sub in any other workbook

(incl
addins), if so did you prefix the way I suggested.

Apart from your Personal.xla do you also have Personal.xls, if so

try
renaming the addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
Peter,

When I do this, and get rid of the menu already in place (but

run
your
code)
I get an error:

The macro" C:\..\AddIns\personal.xla'!AddMenu' cannot be found

do you what this means?

Thanks,
-m

"Peter T" wrote:

Application.OnKey "+^D", "MyMacro"

This should create a shortcut Shift-Ctrl-D. If there's any
possibility
MyMacro may exist in any other workbook prefix with
ThisWorkbook.Name &
"!".
Call it from an Open event.

Not sure about naming your addin "Personal.xla" if there may

also
be a
Personal.xls open, guess it's OK but I wouldn't.

Regards,
Peter T

"mvyvoda" wrote in message
...
i am using an add-in to store macro's ("personal.xla" in
C:\Documents
and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I need

to
have a
keyboard shortcut to one fuction within this add-in. The

macro
list
(Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m














  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Add-In Keyboard Shortcut

I'm sorry I don't follow any of the discussion about menus but I think
I can answer the orginal question. Here are two ways to add a keyboard
shortcut to an add-in subroutine:

Manually:
1) Open the macro listToolsMacroMacros...
2) You won't see your subroutine listed, but when you type in the full
name of the macro the Options button will become enabled. Click the
Options button and enter your shortcut.
3) Be sure to save your add-in from the VBE window.

By Code:
1) Write a Private Sub in your add-in.
2) Enter the following code:
Application.MacroOptions Macro:="MyMacro", _
HasShortCutKey:=True, _
ShortcutKey:="V" 'Alt+Shift+v
3) Run this macro from the VBE window once and save the add-in.

Dave Parker

mvyvoda wrote:
i am using an add-in to store macro's ("personal.xla" in C:\Documents and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I need to have a
keyboard shortcut to one fuction within this add-in. The macro list (Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m


  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Add-In Keyboard Shortcut

This most certainly is a work around that will have to do for now.

Thanks,
-m

" wrote:

I'm sorry I don't follow any of the discussion about menus but I think
I can answer the orginal question. Here are two ways to add a keyboard
shortcut to an add-in subroutine:

Manually:
1) Open the macro listToolsMacroMacros...
2) You won't see your subroutine listed, but when you type in the full
name of the macro the Options button will become enabled. Click the
Options button and enter your shortcut.
3) Be sure to save your add-in from the VBE window.

By Code:
1) Write a Private Sub in your add-in.
2) Enter the following code:
Application.MacroOptions Macro:="MyMacro", _
HasShortCutKey:=True, _
ShortcutKey:="V" 'Alt+Shift+v
3) Run this macro from the VBE window once and save the add-in.

Dave Parker

mvyvoda wrote:
i am using an add-in to store macro's ("personal.xla" in C:\Documents and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I need to have a
keyboard shortcut to one fuction within this add-in. The macro list (Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m



  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Add-In Keyboard Shortcut

Hi Mark,

From Auto_Open should add a MyMacro button to the Tools menu and optionally
delete any old MyMacro that wasn't deleted in a previous Auto_Close (if
indeed you want to delete menu on close). It also adds a version id to the
button's tag property.

Sub Auto_Open()
MyMenu True, 123
End Sub

Sub Auto_Close()
MyMenu False
End Sub

Sub MyMenu(bCreate As Boolean, Optional ver)
Dim cbcTools As CommandBarControl
Dim cbcNew As CommandBarControl

On Error Resume Next
'set a ref to Tools
Set cbcTools = _
Application.CommandBars("Worksheet Menu Bar").FindControl(Id:=30007)

'delete any/all MyMacro buttons
Do
cbcTools.Controls("MyMacro").Delete
Loop Until Err.Number

On Error GoTo 0

If bCreate Then
' you might not want temporary:=True
Set cbcNew = cbcTools.Controls.Add(Type:=1, temporary:=True)
cbcNew.Caption = "&MyMacro"
cbcNew.OnAction = "MyMacro"
cbcNew.Tag = "MyVer" & ver
End If

End Sub

Sub MyMacro()

MsgBox "MyMacro"
End Sub

Regards,
Peter T

PS I accidently posted this earlier today in another thread!
"mvyvoda" wrote in message
...
Peter T,

Haha, sounds like you have a better understanding of this menu dilemma

than
I do. I'm afraid I would struggle for days trying to understand the
complexity of your answer. closed events vs. open, tag properties, etc. i
have an unfortunately long-ish AddMenu module. What are the chances of you
taking a peek at it? Is that asking too much of youru time and energy?

Thanks,
Mark

"Peter T" wrote:

you say it's unconventional to have an entire module dedicated to

adding a
menu (AddMenu).


No I didn't mean that (an entire module etc). I meant unusual to have a
shortcut to a procedure that in turn adds menu item(s), though I think I

now
understand what you are doing.

I would suggest a different approach, and I'm assuming you are not

deleting
the menus in the close event. In the tag property of your menus write
something that identifies your xla version, an id. In the open event try
setting a reference to your menus (under On Error Resume Next). If the

id
refers to an old version delete it and create new menu(s). Also of

course if
the menu doesn't exist create the menu.

Regards,
Peter T

"mvyvoda" wrote in message
...
From the users standpoint, I have a series of macro's that can only

run
from
a menu (as opposed to going into the code and running the macro).

However,
each iteration of my .xla file (which stores the macro's) I change

this
menu.

So, I want to be able to automatically (via ctrl+shift+d sounds

great!) to
change their pre-existing menu to the current one i worked on.

you say it's unconventional to have an entire module dedicated to

adding a
menu (AddMenu). You also say you think it wise to add a menu from

within
another module. Is that what you're saying? I'm not sure if I

follow...
this
line of thinking.

I also think i'm in way over my head :-/ But, it's pretty close....

thanks a lot for your time and effort!!!!,
-m

"Peter T" wrote:

I'm glad you've got it working but not sure I understand your

follow-up
question.

You need to run the code that assigns the shortcut to your AddMenu

proc,
typically from an open event which might also add a menu. There's no

need
for the proc to have run once before it will work from the shortcut.

It's unusual to have a shortcut that runs code to add menu items, at

least I
assume that's what AddMenu does. More conventional would be to have

both
the
OnAction property of a menu item and your shortcut linked to a

procedure
that starts some functional aspect of your addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
oh... I misnamed AddMenu. It works now, however I have a final

question. I
have a scenario whereby I need this ctrl+shift+D to work in a

situation
where
someone has never ran the AddMenu routine. Is this possible? Or,

do I
have
to
run AddMenu with the added ctrl+shift+D code before they can use
ctrl+shift+D?

If you follow?

Thanks,
-m

"mvyvoda" wrote:

I got rid of the menu already in place to test to see if the
ctrl+shift+D
would work if only personal.xla was in place and never ran.

also, i
did
rename the file, to no avail.

I don't have any other macro's that are similarly named.

AddMenu is a pretty typical routine that merely adds a menu,

names
it
and
places arguments (attached to macros of course) within the menu.

Peter, I really appreciate all your help!!,
-m

"Peter T" wrote:

Why do you "get rid of the menu already in place"

Is AddMenu a Sub with no arguments

Do you have a similarly named AddMenu sub in any other

workbook
(incl
addins), if so did you prefix the way I suggested.

Apart from your Personal.xla do you also have Personal.xls, if

so
try
renaming the addin.

Regards,
Peter T

"mvyvoda" wrote in message
...
Peter,

When I do this, and get rid of the menu already in place

(but
run
your
code)
I get an error:

The macro" C:\..\AddIns\personal.xla'!AddMenu' cannot be

found

do you what this means?

Thanks,
-m

"Peter T" wrote:

Application.OnKey "+^D", "MyMacro"

This should create a shortcut Shift-Ctrl-D. If there's any
possibility
MyMacro may exist in any other workbook prefix with
ThisWorkbook.Name &
"!".
Call it from an Open event.

Not sure about naming your addin "Personal.xla" if there

may
also
be a
Personal.xls open, guess it's OK but I wouldn't.

Regards,
Peter T

"mvyvoda" wrote in

message
...
i am using an add-in to store macro's ("personal.xla" in
C:\Documents
and
Settings\mvyvoda\Application Data\Microsoft\AddIns). I

need
to
have a
keyboard shortcut to one fuction within this add-in. The

macro
list
(Alt-F8)
does not list any macro's in personal.xla.

i'm not even sure where to start.

thanks,
-m














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
keyboard shortcut dicksadler Excel Discussion (Misc queries) 0 February 18th 09 11:00 PM
Keyboard shortcut: something new James Silverton[_2_] Excel Discussion (Misc queries) 3 September 23rd 07 01:15 PM
Keyboard shortcut for name box hmm Excel Discussion (Misc queries) 4 August 11th 07 01:02 PM
Keyboard shortcut for Best Fit Ob1Pimpobi Excel Discussion (Misc queries) 1 August 31st 06 01:06 AM
Keyboard Shortcut ArthurJ Excel Discussion (Misc queries) 3 January 12th 06 06:00 AM


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