RE: Creating a Toggle/Command Button with a Text and Picture underlayer?

Capetonian

New Member
Joined
Sep 3, 2011
Messages
5
RE: Creating a Toggle/Command Button with a Text and Picture underlayer?

Hi There, we’re busy with an excel Invoice and want to create a toggle/command button with text and image upload ability.

Below, please find the link to the file for ease of reference.

I’ve also included an explanation of what we would like to do.

Any help or advice will be extremely appreciated.

Thank You!!


http://www.dropbox.com/s/ojg735uu78yekd1/Toggle_Command_Button.docx?dl=0
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Re: Creating a Toggle/Command Button with a Text and Picture underlayer?

.

https://superuser.com/questions/802...n-excel-macro-by-hovering-a-mouse-over-a-cell

Code:
Option Explicit


Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    'Debug.Print Button, Shift, X, Y
    MsgBox "Hi"
    'your macro here or call macro (delete the MsgBox command first)
End Sub



Paste the macro into the SheetLevel module.
 
Last edited:
Upvote 0
Re: Creating a Toggle/Command Button with a Text and Picture underlayer?

Logit, thank you for the response, but please bear in mind that my knowledge regarding Excel VBA is very limited and I'll require a more step by step explanation in achieving my desired result.
 
Upvote 0
Re: Creating a Toggle/Command Button with a Text and Picture underlayer?

.
There are probably several way you can accomplish your goal. The following is just one ....

First, you'll need to have the DEVELOPER tab on your menu bar at the top. If you don't see a tab named DEVELOPER, search the internet for instructions how to show that tab.

You can perform the following on any sheet you desire. For this example we'll presume you are using SHEET 1.

Click DEVELOPER tab / INSERT / under ACTIVEX CONTROLS, select the large "A" which is the icon for an ACTIVEX LABEL. Click it once, then move your mouse
to the cell where you want to place it over. This is the same cell you want to mouse click to perform your Toggle/Command Button action. Left click your mouse and the label
is placed over the cell. You can size the label as needed.

If you have more than one cell you want to do this on, you can create as many ACTIVEX labels as you need, one at a time, repeating these processes.


Right click the label and select PROPERTIES. Change BACKSTYLE to transparent / Delete the CAPTION "Label1" / Make certain VISIBLE is set to TRUE.

Now make certain DESIGN MODE in the menu bar up top is deselected / turned off by clicking on it.

Right click the SHEET 1 tab and select VIEW CODE.

On the left side, double click the Sheet1(Sheet1) name.

In the large code window on the right paste the following :


Code:
Option Explicit


Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)


     MsgBox "Hi"     '<--- this is for testing purposes only. You'll delete this in your final version.


    'your macro here or call macro (delete the MsgBox command)


End Sub

Now, go back to Sheet1 and place your mouse pointer over the cell where the ActiveX Label is located. The MessageBox should auto-appear each time your mouse hovers over the cell.

Having the label over the cell will prevent you from using your mouse to navigate to that cell and enter data. You can use the arrow keys (if needed) to make the cell active, then type
what is required into the cell. Any formulas placed in the cell will function normally as well, after the LABEL is placed over the cell.

When you are ready to insert macro code into the above code, comment out or delete the MsgBox line, then insert your macro code. After that, each time your mouse hovers over the cell,
your macro will auto run.

My view is .... it shouldn't be necessary to have a command button appear first. Eliminate that step and simply show a USERFORM with the food data.

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,214,596
Messages
6,120,438
Members
448,966
Latest member
DannyC96

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top