Add not compiling

  • Thread starter Thread starter will
  • Start date Start date
W

will

I created an add-in with some basic sub routines. I also have a sub
routine that I am using to assign shortcuts to the other subs.
Sub OnKey()
With Application
..OnKey "+^4", "fmtDollar"
..OnKey "+^5", "fmtPercent"
..OnKey "+^1", "fmtComma"
..OnKey "+^`", "fmtGeneral"
End With
End Sub

The problem is that with the add-in loaded, when I open excel, the
shortcut keys don't work. However, if I go into the code and hit F5 to
compile it and then go back to my worksheet the shortcut keys work
fine.
Any ideas as to why I need to compile this everytime? Any help is
greatly appreciated.

Regards,
Will
 
Is there anything in the addin that would make this macro execute when the
addin is loaded. Just like any other workbook, if you want code to run, you
have to trigger it. If you don't, then there's your huckleberry.
 
Seems to me your code (the OnKey... code) is in the wrong place. It'
there but it's not being run until you do it manually. I haven't don
a whole lot of work with addins, but I do believe there should be a wa
to trigget it with the Workbook_Open() event. Check into that and pos
your results. - Piku
 
I used the following to try to get it to "trigger", but it still isn't working.

Private Sub Workbook_Open()
Call OnKey
End Sub

any other ideas?
thx
 
Private Sub Workbook_Open()
With Application
..OnKey "+^4", "fmtDollar"
..OnKey "+^5", "fmtPercent"
..OnKey "+^1", "fmtComma"
..OnKey "+^`", "fmtGeneral"
End With
End Sub

I can't say that naming your procedure ONKEY is the problem, but I would
avoid using that name.
 
Back
Top