CAN I ADD CONTROLX BUTTON TO CUSTOMISED TOOLBARS

J

JASON

I AM TRYING TO CREATE A CUSTOMISED TOOLBARS HOLDING SOME CONTROL X COMMAND
BUTTONS. EG OF HOW THE BUTTON WORKS AS FOLLOWS :

WHEN I CLICK ON THE BUTTON AND HOLD ON TO THE BUTTON, IT WILL CONTINUOUSLY
MOVE THE SELECTED OBJECT SAY A DRAWN RECTANGLE ON A WORKSHEET TO THE LEFT AND
WILL STOP MOVING ONCE I RELEASE THE BUTTON.

I NEED THE BUTTON ON THE TOOLBAR TO BE CONTROL X COS I NEED THE MOUSE CLICK
MOUSE UP EVENTS TO PROGRAM THE ABOVE.

THE REASON WHY I DON USE THE COMMAND BUTTON ON THE WORKSHEET IS BECAUSE WHEN
I SCROLL DOWN THE WINDOW THE COMMAND BUTTON WILL BE OUT OF VIEW. SO I NEED
THE BUTTON TO BE AT THE TOOLBARS SO THAT WHEN I SCROLL TO ANY PORTION OF THE
WORKSHEET, THE COMMAND BUTTION REMAIN IN THE SAME PLACE WHERE I CAN EASILY
ACCESS IT.

OR ANYONE KNOW OF HOW TO STATION A COMMAND BUTTON ON A WORKSHEET AT A
LOCATION SO THAT IT WONT MOVE OUT OF VIEW WHEN I SCROLL THE WINDOW?
 
G

Greg Wilson

This is already supported by the arrow keys.

FYI, for continued execution of a macro, I would take advantage of the fact
that assigning a macro to a keyboard key allows repeated execution while the
key is held down. A macro is continually executed the same way holding down
the "a" key produces a long string of a's ("aaaaaaaaaaaaaa").

I would create the toolbar programmatically on open (which I always do) and
assign the "TogRemap" macro to the desired button. Assumed is that the macros
"Macro1", "Macro2" etc. are your macros. Code examples:

Sub TogRemap()
With Application.CommandBars.ActionControl
If .State = msoButtonUp Then
.State = msoButtonDown
RemapKeys
Else
.State = msoButtonUp
ResetKeys
End If
End With
End Sub

Sub RemapKeys()
With Application
.Cursor = xlNorthwestArrow
.OnKey "{UP}", "Macro1"
.OnKey "{DOWN}", "Macro2"
.OnKey "{LEFT}", "Macro3"
.OnKey "{RIGHT}", "Macro4"
End With
End Sub

Sub ResetKeys()
With Application
.Cursor = xlDefault
.OnKey "{UP}"
.OnKey "{DOWN}"
.OnKey "{LEFT}"
.OnKey "{RIGHT}"
End With
End Sub

Regards,
Greg
 
G

Greg Wilson

Just in case my first post wasn't clear, from what you describe, you probably
don't need any code or toolbar at all. Just use the arrow keys while the
object is selected.
My code examples were only intended for general info.

I've done the same thing you describe with photos except I select them by
simply holding the mouse pointer over the desired photo (don't like the look
of the sizing handles). However, the code that translates mouse coordinates
to excel's points that allows identification of the selected object isn't
that simple.

Greg
 
W

Wei Lu [MSFT]

Hi ,

How is everything going? Please feel free to let me know if you need any
assistance.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top