How to record keystrokes and mouse clicks in a macro?

komobu

New Member
Joined
Feb 7, 2011
Messages
34
I saw some instructions on placing images in a comment so that when I click on the cell, I can view the image. Here is an example:
1.insert coment
2.view comment
3. right click on the comment then right click the grey border of the comment(not in the comment itself)
4.click format comment
5.choose the colours and lines tab
6.click the color drop down
7.at the bottom select "fill effects"
8.click the picture tab
9. click select picture button
9.choose pic from wherever
10 click all the ok's

Now I would like to record all of this as a macro and place a Macro Button on my toolbar so all I have to do is click it and a directory will pop up asking me to choose the jpg file. Is this possible? any help on creating the macro would be appreciated.



I would also like the same procedure with a webcam image. Is this possible? Thanks for any input.
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,531
Did you actual use the macro recorder and see what it produced?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,116
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Something like this:
Code:
Sub GetCommentPic()
   Dim PicFile
   PicFile = Application.GetOpenFilename("JPEG files (*.jpg), *.jpg, Bitmap files (*.bmp), *.bmp")
   If PicFile <> False Then
      ActiveCell.AddComment
      ActiveCell.Comment.Shape.Fill.UserPicture PicFile
   End If
End Sub
 

komobu

New Member
Joined
Feb 7, 2011
Messages
34
Rory;

Thanks! That is exactly what I am looking for! What commands would I use to resize the comment? I tried:

ActiveCell.Comment.Size.Height = "2.5"
ActiveCell.Comment.Size.Width = "4.0"

They returned an error.

Also, how can I put the macro on the tool bar?

Thanks again for your help
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,116
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Code:
With ActiveCell.Comment.Shape
   .Height = 2.5
   .Width = 4
End With
 

Watch MrExcel Video

Forum statistics

Threads
1,122,912
Messages
5,598,833
Members
414,260
Latest member
joishe

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
Top