can anyone tell me how to insert an image into excel so it appears in the
same place every time also so it resizes to the merged cells i have created
can anyone tell me how to insert an image into excel so it appears in the
same place every time also so it resizes to the merged cells i have created
one way:
Insert the image then run this macro. Adjust the cell reference as
desired:
Public Sub PositionAndScalePic()
Dim rArea As Range
Dim dFactor As Double
Set rArea = ActiveSheet.Range("J5").MergeArea
With ActiveSheet.Pictures
With .Item(.Count)
.Top = rArea.Top
.Left = rArea.Left
dFactor = rArea.Width / .Width
.Width = rArea.Width
.Height = .Height * dFactor
If .Height > rArea.Height Then
dFactor = rArea.Height / .Height
.Height = rArea.Height
.Width = .Width * dFactor
End If
.Placement = xlMoveAndSize
End With
End With
End Sub
In article <CE1B0123-C883-40FD-91F3-2BFDF43C139D@microsoft.com>,
"dave" <dave@discussions.microsoft.com> wrote:
> can anyone tell me how to insert an image into excel so it appears in the
> same place every time also so it resizes to the merged cells i have created
Do you know how should I modify this code for uploaded picture to be scaled with locked aspect ratio for full width of merged cells?Public Sub PositionAndScalePic()
Dim rArea As Range
Dim dFactor As Double
Set rArea = ActiveSheet.Range("J5").MergeArea
With ActiveSheet.Pictures
With .Item(.Count)
.Top = rArea.Top
.Left = rArea.Left
dFactor = rArea.Width / .Width
.Width = rArea.Width
.Height = .Height * dFactor
If .Height > rArea.Height Then
dFactor = rArea.Height / .Height
.Height = rArea.Height
.Width = .Width * dFactor
End If
.Placement = xlMoveAndSize
End With
End With
End Sub
Regards,
Marcin
Hi, Marcin4111,
Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.
If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.
Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
And please use code-tags instead of quote-tags to display code.
Ciao,
Holger
Use Code-Tags for showing your code: [code] Your Code here [/code]
Please mark your question Solved if there has been offered a solution that works fine for you
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks