Greetings All,
I have an Excel application that will use the Excel function to insert an image inside a cell. It is my understanding that the function to insert an image inside a cell is also associated with the IMAGE function which is available in Excel 365 but not earlier versions such as Excel 2019.
I was searching around and found VBA code I adapted for my use ...
I must be doing something wrong because I can never force the error condition. For example, if change this line
to this ...
The resulting target cell displays #NAME which I would expect. But, the VBA code does not trap the error condition.
Appreciate any help.
Regards,
Steve
I have an Excel application that will use the Excel function to insert an image inside a cell. It is my understanding that the function to insert an image inside a cell is also associated with the IMAGE function which is available in Excel 365 but not earlier versions such as Excel 2019.
I was searching around and found VBA code I adapted for my use ...
VBA Code:
Sub CheckExcel ()
' Attempt to use the IMAGE function.
On Error Resume Next
Sheet5.Range("excelIMAGEtarget").Formula = "=IMAGE(""https://reservestudyhoa.com/images/diyimage_small.jpg"")"
' Check if the function was accepted
If Err.Number = 0 Then
Sheet5.Range("excelsupported").Value = "TRUE"
Err.Clear
MsgBox "This version of Excel supports the IMAGE function."
On Error GoTo 0
Exit Sub
Else
Sheet5.Range("excelsupported").Value = "FALSE"
MsgBox "This version of Excel does not support the IMAGE function."
Err.Clear
On Error GoTo 0
Exit Sub
End If
End Sub
I must be doing something wrong because I can never force the error condition. For example, if change this line
VBA Code:
Sheet5.Range("excelIMAGEtarget").Formula = "=IMAGE(""https://reservestudyhoa.com/images/diyimage_small.jpg"")"
to this ...
VBA Code:
Sheet5.Range("excelIMAGEtarget").Formula = "=IMAGEX(""https://reservestudyhoa.com/images/diyimage_small.jpg"")"
The resulting target cell displays #NAME which I would expect. But, the VBA code does not trap the error condition.
Appreciate any help.
Regards,
Steve