Dear all,
I am new at Marcos. I have to insert a lot of pictures into various Excel worksheet. The Macro is created by someone else.
Every time I open the file, some pictures are zoomed-in or completely blurred at random. The one time it concerns picture X, the other time it is picture Y.
Most of the times I use the "Insert Picture Here" button, which was especially created to avoid formatting errors. However, there were some occasions where I used "Insert > Image" from the Excel Menu.
Here is the Add_Pic Macro code:
Sub Auto_Open()
Sheets("MENU").Activate
End Sub
Sub Add_Pic()
If Not Intersect(ActiveCell, Range("FotoRange")) Is Nothing Then
Dim oActive As Worksheet
Dim oShape As Shape
Dim vSelection As Variant
Dim lTop As Long
Dim lLeft As Long
Set oActive = ThisWorkbook.ActiveSheet
'Allow the user to browse for an image file
vSelection = Application.GetOpenFilename("Graphics files (*.gif;*.jpg), *.gif;*.jpg")
If vSelection = False Then
MsgBox "Select an image"
Exit Sub
End If
lTop = Selection.Top
lLeft = Selection.Left
'Insert the image at the fixed size 80 X 80 and then reset size to 100%
Set oShape = oActive.Shapes.AddPicture(vSelection, True, True, lLeft, lTop, Range("FotoBreedte"), Range("FotoHoogte"))
oShape.ScaleHeight 1, msoTrue
oShape.ScaleWidth 1, msoTrue
oShape.SoftEdge.Type = msoSoftEdgeType1
'Name the shape "Picture" with the cell address appended
oShape.Name = "Picture" & Selection.Address
Else
MsgBox "You can only insert a picutre in the designated cells. Place your cursos on a cell and add the button "Insert Picture Here."
End If
End Sub
[/COLOR][/COLOR][/COLOR]
The Excel file is basically a template for setting up Work Instructions for our production facility. Therefore, the pictures have an important function as they visualize the various steps in the Work Instructions. The problem thus needs to be fixed otherwise the files are of no use due to reliability issues. Here is a screenshot of a part of the worksheet. The second image is zoomed in, only a detail is visible.
Worksheet.jpg
Could there be something wrong with the Macro code?
Thanks a lot for your help.
Kind regards,
Eline de Vrij
Bookmarks