An Error Occoured while Importing this file excel VBA

mickyflash

Board Regular
Joined
Jan 29, 2009
Messages
77
Help!

I have used this code for a couple of years now without any issues, however all of a sudden excel is not liking it and I am not sure what has changed.

3.png


Excel uses this code:

VBA Code:
Sub table_pic11()
Dim Pshp As Shape
Dim xRg As Range
Dim xCol As Long
On Error Resume Next
Application.ScreenUpdating = False
Set rng = ActiveSheet.Range("B238:V340")
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 + 31
Set xRg = Cells(cell.Row, xCol)
With Pshp
.LockAspectRatio = msoFalse
If .Width > xRg.Width Then .Width = xRg.Width * 2 / 3
If .Height > xRg.Height Then .Height = xRg.Height * 2 / 3
.Top = xRg.Top + (xRg.Height - .Height) / 2
.Left = xRg.Left + (xRg.Width - .Width) / 2
End With
lab:
Set Pshp = Nothing
Range("w22").Select
Next
Application.ScreenUpdating = True
    
End Sub

to scan through the links on the left and pull the relevant picture on the right however I am getting a red x image can not be found on each row, despite the links being of the correct address and displaying where they should be on the spreadsheet!

How do I get rid of the red X's?

I am also using this code

VBA Code:
Public Sub Add_Images_To_Cells9()
    
    Dim lastRow As Long
    Dim URLs As Range, URL As Range, shpCel As Range
    Dim shp As Shape, N As String
   
    With ActiveSheet
        lastRow = .Cells(.Rows.Count, "y").End(xlUp).Row
        Set URLs = .Range("y100:y220")

        For Each URL In URLs
            URL.Offset(0, 5).Select
            On Error Resume Next
            URL.Parent.Pictures.Insert URL.Value
            DoEvents
            Set shp = .Shapes(.Shapes.Count)
            If Not URL.Offset(, 1) Then shp.PictureFormat.ColorType = 1
        Next URL
    End With


    
End Sub

To display images, but this is now bringing up an error message saying An Error Occoured while Importing this file. with an OK box pop up.

No image is displayed on this occasion, and I have to manually overide the macro by clicking OK.
There are over 500 images per spreadsheet and nothing is importing correctly now, what could have gone wrong?

I have tried updating excel, restoring the file to a previous version, deleting my temp folder, updating my privacy records and going through to see if an excel option has changed but to no avail.

Your my last hope guys. please help!
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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