Inserting images into Excel workbook - loss of image quality problem

Unlocking5447

New Member
Joined
Sep 19, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,

I’m having a problem with resolution loss of images inserted into an Excel workbook and, after several hours, still haven’t come up with a solution.

The issue is as follows: I have an Excel workbook with thousands of rows of data. I’ve added a column where I want to place an image for most of these rows. I have already disabled the image compression in the “Options” “Advanced” for the workbook and selected “High Fidelity” for the default resolution. The images are in TIF format, but I have also tried converting them into PNG with the same issues. I am selecting the cell and then inserting the image using the ‘insert’ tab on the ribbon, then “pictures” and “place in cell” etc. (copying and then pasting from the clipboard does not work for some reason). When an image is inserted it looks fine but if I toggle the ‘place in cell’ ‘place over cell’ using the little picture icon at the top right of the image, then the resolution quality is reduced. With some files the reduction is worse than others (I haven’t worked out why this is), but I don’t want any resolution loss at all as this workbook. Here are a couple of examples. In each case the image on the left has not been manipulated after being inserted, the one on the right has been toggled as described above.

Thank you for any assistance you can provide.

Both the ones below show the inserted graph on the left and the toggled graph on the right – both lose resolution, although the second example shows the problem more dramatically.
 

Attachments

  • Image.png
    Image.png
    45.7 KB · Views: 12

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I store the full rez images on the server (as read only) : \\server\folder\image1.jpg
this full path is in a cell, in excel.

then i open it with the code below that opens any document/image in it's native app.
.jpg opens in Paint,
.Docx opens in word, etc...

i put an icon on the Quick Access toolbar to run it. It opens the cell the cursor is on,
run macro: OpenImage()

if the file exists, then it will open it in a better app than excel.

Code:
Option Compare Database
Option Explicit


#If Win64 Then
  'Declare PtrSafe Sub...
    Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
    Declare PtrSafe Function GetDesktopWindow Lib "user32" () As Long
#Else
   Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
   Private Declare Function GetDesktopWindow Lib "user32" () As Long
#End If

Const SW_SHOWNORMAL = 1
Const SE_ERR_FNF = 2&
Const SE_ERR_PNF = 3&
Const SE_ERR_ACCESSDENIED = 5&
Const SE_ERR_OOM = 8&
Const SE_ERR_DLLNOTFOUND = 32&
Const SE_ERR_SHARE = 26&
Const SE_ERR_ASSOCINCOMPLETE = 27&
Const SE_ERR_DDETIMEOUT = 28&
Const SE_ERR_DDEFAIL = 29&
Const SE_ERR_DDEBUSY = 30&
Const SE_ERR_NOASSOC = 31&
Const ERROR_BAD_FORMAT = 11&

public sub  OpenImage()

if dir(Activecell.value)<> "" then OpenNativeApp activecell.value

end sub


private Sub OpenNativeApp(ByVal psDocName As String)
Dim r As Long, Msg As String

r = StartDoc(psDocName)
If r <= 32 Then
    'There was an error
    Select Case r
        Case SE_ERR_FNF
            Msg = "File not found"
        Case SE_ERR_PNF
            Msg = "Path not found"
        Case SE_ERR_ACCESSDENIED
            Msg = "Access denied"
        Case SE_ERR_OOM
            Msg = "Out of memory"
        Case SE_ERR_DLLNOTFOUND
            Msg = "DLL not found"
        Case SE_ERR_SHARE
            Msg = "A sharing violation occurred"
        Case SE_ERR_ASSOCINCOMPLETE
            Msg = "Incomplete or invalid file association"
        Case SE_ERR_DDETIMEOUT
            Msg = "DDE Time out"
        Case SE_ERR_DDEFAIL
            Msg = "DDE transaction failed"
        Case SE_ERR_DDEBUSY
            Msg = "DDE busy"
        Case SE_ERR_NOASSOC
            Msg = "No association for file extension"
        Case ERROR_BAD_FORMAT
            Msg = "Invalid EXE file or error in EXE image"
        Case Else
            Msg = "Unknown error"
    End Select
'    MsgBox msg
End If
End Sub

Private Function StartDoc(psDocName As String) As Long
Dim Scr_hDC As Long

Scr_hDC = GetDesktopWindow()
StartDoc = ShellExecute(Scr_hDC, "Open", psDocName, "", "C:\", SW_SHOWNORMAL)
End Function
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,989
Members
452,541
Latest member
haasro02

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