ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add not compiling (https://www.excelbanter.com/excel-programming/298690-add-not-compiling.html)

will

Add not compiling
 
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

Tom Ogilvy

Add not compiling
 
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.

--
Regards,
Tom Ogilvy

"will" wrote in message
om...
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




pikus

Add not compiling
 
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

--
Message posted from http://www.ExcelForum.com


will

Add not compiling
 
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

"Tom Ogilvy" wrote in message ...
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.

--
Regards,
Tom Ogilvy

"will" wrote in message
om...
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


Tom Ogilvy

Add not compiling
 
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.

--
Regards,
Tom Ogilvy


"will" wrote in message
m...
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

"Tom Ogilvy" wrote in message

...
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.

--
Regards,
Tom Ogilvy

"will" wrote in message
om...
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





All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com