ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   force keyboard (ALT) shortcuts in VBA Code? (https://www.excelbanter.com/excel-programming/315726-force-keyboard-alt-shortcuts-vba-code.html)

Steve Mackay[_2_]

force keyboard (ALT) shortcuts in VBA Code?
 
Is it possible to force your vba code to use keyboard shortcuts - like "CTRL
+ C" or "ALT + E + C+ENTER" instead of "Selection.Copy".

The reason why I ask is that I have an add-in menu in Excel located between
the "Data" & "Windows" menus that I would like to access in a macro. The
shortcut would be "ALT +L+A+ENTER

Thanks,
Steve



Jim Cone

force keyboard (ALT) shortcuts in VBA Code?
 
Steve,

The direct answer to your questions is to tell you to look at "SendKeys" in help.
A easier method would be to set a reference to the Add-in in Tools | References in the VBE.
That will allow you to call the macro using the run method...

Application.Run("MacroName")

Regards,
Jim Cone
San Francisco, CA

"Steve Mackay" wrote in message
...
Is it possible to force your vba code to use keyboard shortcuts - like "CTRL
+ C" or "ALT + E + C+ENTER" instead of "Selection.Copy".
The reason why I ask is that I have an add-in menu in Excel located between
the "Data" & "Windows" menus that I would like to access in a macro. The
shortcut would be "ALT +L+A+ENTER
Thanks,
Steve



Steve Mackay[_2_]

force keyboard (ALT) shortcuts in VBA Code?
 
Thanks for the tip. I understand it in concept but can't seem to get it to
work in practice. So, to go back to my paste example, my code would look
like this?

Sub test()
Application.SendKeys ("%ep")
End Sub

But that doesn't seem to work correctly. Can you give me an example.
Sorry, I know this is probably very basic programming, but I appreciate your
help.

Steve

"Jim Cone" wrote in message
...
Steve,

The direct answer to your questions is to tell you to look at "SendKeys"
in help.
A easier method would be to set a reference to the Add-in in Tools |
References in the VBE.
That will allow you to call the macro using the run method...

Application.Run("MacroName")

Regards,
Jim Cone
San Francisco, CA

"Steve Mackay" wrote in message
...
Is it possible to force your vba code to use keyboard shortcuts - like
"CTRL
+ C" or "ALT + E + C+ENTER" instead of "Selection.Copy".
The reason why I ask is that I have an add-in menu in Excel located
between
the "Data" & "Windows" menus that I would like to access in a macro. The
shortcut would be "ALT +L+A+ENTER
Thanks,
Steve





Jim Cone

force keyboard (ALT) shortcuts in VBA Code?
 
Steve,

If you want to paste then these work...

Application.SendKeys ("%(e)p~") ' I added the enter key

Application.SendKeys ("^(v)") ' or
Application.SendKeys ("^v") ' without the ()

Remember to do this from the spreadsheet, not from the VBE.

Also, note that there are two versions of SendKeys...
omit "Application" to send to the active window.
use "Application" to send to the application.

Experiment a little.

I still recommend Application.Run("Name of Sub")

Regards,
Jim Cone
San Francisco, CA

"Steve Mackay" wrote in message
...
Thanks for the tip. I understand it in concept but can't seem to get it to
work in practice. So, to go back to my paste example, my code would look
like this?

Sub test()
Application.SendKeys ("%ep")
End Sub

But that doesn't seem to work correctly. Can you give me an example.
Sorry, I know this is probably very basic programming, but I appreciate your
help.
Steve


"Jim Cone" wrote in message
...
Steve,

The direct answer to your questions is to tell you to look at "SendKeys"
in help.
A easier method would be to set a reference to the Add-in in Tools |
References in the VBE.
That will allow you to call the macro using the run method...

Application.Run("MacroName")

Regards,
Jim Cone
San Francisco, CA

"Steve Mackay" wrote in message
...
Is it possible to force your vba code to use keyboard shortcuts - like
"CTRL
+ C" or "ALT + E + C+ENTER" instead of "Selection.Copy".
The reason why I ask is that I have an add-in menu in Excel located
between
the "Data" & "Windows" menus that I would like to access in a macro. The
shortcut would be "ALT +L+A+ENTER
Thanks,
Steve



Steve Mackay[_2_]

force keyboard (ALT) shortcuts in VBA Code?
 
Thanks,
I'll play with it a bit. I don't understand the last thing you said, but
I'll look into it.

Steve

"Jim Cone" wrote in message
...
Steve,

If you want to paste then these work...

Application.SendKeys ("%(e)p~") ' I added the enter key

Application.SendKeys ("^(v)") ' or
Application.SendKeys ("^v") ' without the ()

Remember to do this from the spreadsheet, not from the VBE.

Also, note that there are two versions of SendKeys...
omit "Application" to send to the active window.
use "Application" to send to the application.

Experiment a little.

I still recommend Application.Run("Name of Sub")

Regards,
Jim Cone
San Francisco, CA





All times are GMT +1. The time now is 07:23 PM.

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