ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help Please - picture not embedding (https://www.excelbanter.com/excel-programming/451260-help-please-picture-not-embedding.html)

[email protected]

Help Please - picture not embedding
 
Hi

I found the code below (which I've adapted slightly)on OZGrid. I was under the impression this would embed the picture. However having tested it by emailing to someone else it is actually linking the picture (emailed s/sheet has a box saying the linked image cannot be displayed).

What I'd like it to do is take the user to a browse to a graphic, embed the graphic in the spreadsheet and resize the graphic. As it stands the macro works perfectly apart from not embedding it.

Any help greatly appreciated! Thanks in advance.

Steve

Sub InsertImageLumindoor1()

Dim myFiles, e

myFiles = Application.GetOpenFilename(, , , , True)
If Not IsArray(myFiles) Then Exit Sub
For Each e In myFiles
With ActiveSheet
With .Pictures.Insert(e)
.Left = Range("A20").Left
.Top = Range("B20").Top
.ShapeRange.LockAspectRatio = msoFalse
.Height = 160
.Width = 287
End With
End With

Next

End Sub

Robert Crandal[_3_]

Help Please - picture not embedding
 
See if this works for you:

Sub myImageEmbed()

Dim fn As Variant
fn = Application.GetOpenFilename(FileFilter:="JPEG Files (*.JPG), *.JPG",
Title:="Select File To Be Opened")

Set myDocument = Worksheets(1)

If fn = False Then
' Do nothing if no file selected
Else
' Set image position and size here
myDocument.Shapes.AddPicture fn, True, True, 100, 100, 70, 70
End If

End Sub




[email protected]

Help Please - picture not embedding
 
On Friday, January 15, 2016 at 12:37:33 PM UTC, Robert Crandal wrote:
See if this works for you:

Sub myImageEmbed()

Dim fn As Variant
fn = Application.GetOpenFilename(FileFilter:="JPEG Files (*.JPG), *.JPG",
Title:="Select File To Be Opened")

Set myDocument = Worksheets(1)

If fn = False Then
' Do nothing if no file selected
Else
' Set image position and size here
myDocument.Shapes.AddPicture fn, True, True, 100, 100, 70, 70
End If

End Sub


Absolutely spot on! Many thanks Robert.


All times are GMT +1. The time now is 12:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com