Hi! To insert pictures, I use the .Shapes.AddPicture so that the pictures aren't being treated as a hyperlink.
The issue I'm having is that when my code runs and it inserts a picture, sometimes the picture is grainy or if I adjust the picture, it is grainy. I noticed that 'use default resolution' is checked in the 'Compress Pictures' section.
It seems to be much better if I:
The issue I'm having is that when my code runs and it inserts a picture, sometimes the picture is grainy or if I adjust the picture, it is grainy. I noticed that 'use default resolution' is checked in the 'Compress Pictures' section.
It seems to be much better if I:
- Select the picture
- Picture Format
- Compress Pictures
- Select HD (330 ppi): good quality for high-definition (HD) displays
VBA Code:
Dim fNameAndPath As Variant
Dim rng As Range
Dim img As Shape
fNameAndPath = Application.GetOpenFilename( _
FileFilter:="Image Files (*.gif;*.jpg;*.png), *.gif;*.jpg;*.png", _
Title:="Select an Image", _
ButtonText:="Select")
If fNameAndPath = False Then Exit Sub
Set rng = ActiveCell
Set img = ActiveSheet.Shapes.AddPicture(fileName:=fNameAndPath, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=0, Top:=0, Width:=-1, Height:=-1)
With img
If .Width > .Height Then
.Width = rng.Width * 0.7
Else
.Height = rng.Height * 0.7
End If
.Left = rng.Left + (rng.Width - .Width) / 2
.Top = rng.Top + (rng.Height - .Height) / 2
.Placement = 1
.PrintObject = True
End With