-
Solved: Insert .JPEG
Hello Everyone,
I have a worksheet using the following code to retrieve a .jpeg and insert on to the worksheet:
[VBA]Sub InsertDCPic()
Dim vFilename As Variant
Dim sPath As String
sPath = "c:\"
ChDrive sPath
ChDir sPath
vFilename = Application.GetOpenFilename("picture files (*.jpg),*.jpg", , "Please Select Die Cut Picture To Place On Warehouse Master", , False)
If TypeName(vFilename) = "Boolean" Then Exit Sub
If CStr(vFilename) = "" Then Exit Sub
If Dir(CStr(vFilename)) <> "" Then
ActiveSheet.Pictures.Insert CStr(vFilename)
End If
End Sub[/VBA]
Is it possible to use VBA code to insert the .jpeg into a specific cell range automatically? If so can this be done if this cell range is unlocked and the rest of the worksheet is protected?
Thank you in advance for any assistance you can provide!!!
-
[VBA]Sub InsertDCPic()
Dim vFilename As Variant
Dim sPath As String
Dim s As Shape, r As Range
sPath = "c:\"
ChDrive sPath
ChDir sPath
vFilename = Application.GetOpenFilename("picture files (*.jpg),*.jpg", , "Please Select Die Cut Picture To Place On Warehouse Master", , False)
If TypeName(vFilename) = "Boolean" Then Exit Sub
If CStr(vFilename) = "" Then Exit Sub
If Dir(CStr(vFilename)) <> "" Then
'Set pic = LoadPicture(CStr(vFilename))
Set r = Range("B5")
Set s = ActiveSheet.Shapes.AddPicture(CStr(vFilename), msoFalse, msoTrue, r.Left, r.Top, 36, 36)
s.TopLeftCell = Range("B5")
End If
End Sub[/VBA]
-
Dear Kenneth,
I like the way it work but wonder if it's possible to place the picture where the cursor is and then insart the pic there to make it possible to upload more pictures and not only one cell as "B5"
Many thanks
-
Change Range("B5") to ActiveCell.
-
Thank you for your help!!
-
-
Many thanks for a nice share
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules