How to insert (filenam) as PNG

Dojorgen

Board Regular
Joined
Mar 1, 2018
Messages
59
Hey guys always such great help:)

this macro works great i found online except for one flaw, it keeps the filenam as a string so when i go back and reopen the workbook it re-pulls all the filenam links. This ends up crashing the server which some folks are not too happy with me about:mad:

Is there any way i could import the filenam but have the image populate as say a PNG or something so it does not keep pulling that link?

I tried a few different ways but it does not seem to be working.

Any help would be appreciated....:confused:



Sub URLPictureInsert1()
Worksheets("Data Entry").Select
Dim Pshp As Shape
Dim xRg As Range
Dim xCol As Long
On Error Resume Next
Application.ScreenUpdating = True
Set Rng = ActiveSheet.Range("AE2:AE415")
For Each cell In Rng
filenam = cell
ActiveSheet.Pictures.Insert(filenam).Select
Set Pshp = Selection.ShapeRange.Item(1)
If Pshp Is Nothing Then GoTo lab
xCol = cell.Column - 13
Set xRg = Cells(cell.Row, xCol)
With Pshp
.LockAspectRatio = msoFalse
.Width = 300
.Height = 75
.Top = xRg.Top + (xRg.Height - .Height)
.Left = xRg.Left + (xRg.Width - .Width)
Selection.Placement = xlMoveAndSize

Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.ScaleWidth 0.48, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.PictureFormat.Crop.PictureWidth = 299
Selection.ShapeRange.PictureFormat.Crop.PictureHeight = 75
Selection.ShapeRange.PictureFormat.Crop.PictureOffsetX = 78
Selection.ShapeRange.PictureFormat.Crop.PictureOffsetY = 0
End With


lab:
Set Pshp = Nothing
Range("Q2").Select
Next
Application.ScreenUpdating = False
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

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