inserted picture sized to cell wanting to mouse over to see larger image doing this few steps as possible

BobColorado

New Member
Joined
Jun 19, 2020
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Recent had some assistance with text in a cell and shown using macros, Alt+F8 AddNote copies the properties of the text and color of background, allowing a larger size and comment triangle.
I tried to apply this to picture i size to fit with in the cell, and the cell box itself and both show runtime error pop up Visual Basic.
I know of another way to do this mouse over, and it has or seems to have plenty of steps to achieve the result. Can you magic wizards of Excel, help and show me the steps and the way?

1592600979725.png
this shows what i have in my document with the macro cover up to show indicators when printing.

Related, interest is to show the Red comment indicator when printing, and i have done this to my main document as it covers up the displayed indicator and shows up for printing, but i want to know if this can be added to or can more than one Macros be stacked together/added together to do different things? I am wondering now, if i use the Alt+F8 select AddNote, then want to (if i can) add the cover up indicator, can or how is this done as well.

I am a novice to the wizardly tricks using Excel.

Thank you for any and all help.
 

Attachments

  • 1592600375131.png
    1592600375131.png
    7.6 KB · Views: 10
  • 1592600386740.png
    1592600386740.png
    1.6 KB · Views: 10

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
welcome to MrExcel :)

post your code
- click on <vba/> and paste your existing code between the code tags
thansk
 
Upvote 0
Here is the code used for the cover up to show the corner identifier.
Sub CoverCommentIndicator()
'www.contextures.com/xlcomments03.html
Dim ws As Worksheet
Dim cmt As Comment
Dim rngCmt As Range
Dim shpCmt As Shape
Dim shpW As Double 'shape width
Dim shpH As Double 'shape height

Set ws = ActiveSheet
shpW = 6
shpH = 4

For Each cmt In ws.Comments
Set rngCmt = cmt.Parent
With rngCmt
Set shpCmt = ws.Shapes.AddShape(msoShapeRightTriangle, _
rngCmt.Offset(0, 1).Left - shpW, .Top, shpW, shpH)
End With
With shpCmt
.Flip msoFlipVertical
.Flip msoFlipHorizontal
.Fill.ForeColor.SchemeColor = 10 'Red
'12=Blue, 57=Green
.Fill.Visible = msoTrue
.Fill.Solid
.Line.Visible = msoFalse
End With
Next cmt

End Sub

HERE is the code Mr. Excel helped me with to do quicker text in a cell to comment box:
Sub AddNote()
For Each cell In Selection
cell.ClearComments
cell.AddComment
cell.Comment.Visible = True
cell.Comment.Shape.Select True
cell.Comment.Text Text:=cell.Value
With Selection.Font
.Name = cell.Font.Name
.Size = cell.Font.Size
.Color = cell.Font.Color
End With
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.ForeColor.RGB = cell.Interior.Color
cell.Select
cell.Comment.Visible = False
Next cell
End Sub

Thank you for your response and interest in my request to see if this can be done.

Bob
 
Upvote 0
Is this what you are looking for ?

VBA Code:
Sub AddImageToComment()
    With ActiveCell
        .ClearComments
        .AddComment
        With .Comment
            .Visible = True
            .Shape.Select True
            .Shape.Fill.UserPicture ("C:\Users\BobColorado\Pictures\MyImage.jpg")
            .Shape.ScaleHeight 2, msoFalse, msoScaleFromTopLeft
            .Shape.ScaleWidth 2, msoFalse, msoScaleFromTopLeft
            .Visible = False
        End With
    End With
End Sub
 
Upvote 0
Hello Yongle and Thank You for trying to work on my interest and sorry i am not all that helpful to you. The only codes i think i have were in in a previous post above.

The sample screen capture above gives the type of image items trying to work with.
The inserted photo sized down to fit into cell is what i what looking to mouse over to see larger size.
Thank you.
 
Upvote 0
Select a cell which already contains an image inside a comment and run code below
Image is copied to cell and mouse-over shows the image inside comment

VBA Code:
Sub AddCommentImageToCell()
    On Error Resume Next
    With ActiveCell
            With .Comment
                .Visible = True
                .Shape.CopyPicture Appearance:=xlScreen, Format:=xlPicture
                .Visible = False
            End With
        .Select
        .PasteSpecial
        Selection.ShapeRange.LockAspectRatio = msoFalse
        Selection.Width = .Width
        Selection.Height = .Height
    End With
    On Error GoTo 0
End Sub

Comment.jpg
 
Last edited:
Upvote 0
Hello Yongle and hope all is well where ever in this world you are.

As i try your code and the steps to do it. Knowing a little more through some of this process, it is different than what i am or was thinking initially? (where i placed an image into a cell, not really sized to fit or locked to the cell, then hoping some way to mouse over and the image becomes bigger. We are kind of there. I also understand now, not as simple as i just said or though it could be.
Your latest code and example, i have tried it and i see the comment box is its normal size and needs to be edited to place the photo and sizing desired. Once Run code has been done and the image moves with in the cell size, anyone wants to make adjustments to the comment box size i have found that i have to click on the small image in the cell to use the handles to size it down. Then i can right click to edit comment, which cant be done with fuller image filling the cell. Part of the learning process?
Hope i haven't confused you by my explanation and partial asking if there is something i may not be doing to achieve editing comment etc?
THANK YOU for your work and understanding with a newbie trying to get better and do more in Excel.

Bob
 
Upvote 0
Sorry I do not understand what you want
 
Upvote 0
That's OK Yongle. I will review my thoughts and apply your codes and see if i have an ongoing need or not. I will be away from work computer for a couple weeks, trying to safely vacation?? Will be working from home after and return to the thread and potentially go from there. Again, Thank You for your time and patience.
Bob
 
Upvote 0

Forum statistics

Threads
1,214,552
Messages
6,120,172
Members
448,948
Latest member
spamiki

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