Forum Discussion

lazuli1485's avatar
lazuli1485
Copper Contributor
Nov 09, 2022

VBA code fails in newest build

Hi,

 

I have had this line of code in a macro for many years

 

 

 

Set ImageToAdd = ActiveSheet.Shapes.AddPicture(ImageURL, True, False, _
Cells(RowToAddImage, ColumnToAddImage).Left + 6, _
Cells(RowToAddImage, ColumnToAddImage).Top + (Cells(RowToAddImage, ColumnToAddImage).Height / 2), -1, -1)

 

 

 

where ImageURL is a valid url for an image that is publicly available on the internet.

 

This works as expected in 

 

Microsoft® Excel® for Microsoft 365 MSO (Version 2210 Build 16.0.15726.20068) 32-bit

 

But is throwing the following error in version 2210 Build 15726.20174

 

Run-time error 1004. The specified file was not found.

 

Could anyone advise a solution or how I should report this as an issue to MS?

 

Thanks,

Richard

7 Replies

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    lazuli1485 

    I think this could be because the macro was placed at the worksheet level

    ...without being sure as don't have a full picture of the code/file/intend.

     

    Try right-clicking on the module node in the VBA project window,

    click "Insert" => "Module"

    and then paste your macro into the new module

    (make sure you use the macro recorded at worksheet level Clear).

     

    Hope I could help you with these information / links.

     

    NikolinoDE

    I know I don't know anything (Socrates)

    • lazuli1485's avatar
      lazuli1485
      Copper Contributor

      NikolinoDE 

      Thank you for the suggestion. Unfortunately not - the line is in a module and always has been.

      • mtarler's avatar
        mtarler
        Silver Contributor
        are you sure RowToAddImage, ColumnToAddImage are both valid and don't have or result in a bad reference

Resources