Hello everyone,
I'm new to the site and I'm hoping someone can be of assistance. I'm using Excel 2010 but others in the company is running on Mac, using Excel 2011 for Mac or MS Office Excel 2013. The following code works for me with no issue (I'll attach the spreadsheet as well):
Option Explicit
Public Sub Add_Pic()
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 a File Please!!!"
Exit Sub
End If
'Offset the top left corner of the image to be in the
'center of the selected cell
lTop = Selection.Top + (Selection.Height / 2)
lLeft = Selection.Left + (Selection.Width / 2)
'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, 80, 80)
oShape.ScaleHeight 1, msoTrue
oShape.ScaleWidth 1, msoTrue
'Name the shape "Picture" with the cell address appended
oShape.Name = "Picture" & Selection.Address
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim oShape As Shape
Dim sName As String
'Toggle picture visibility when the cell in which
'the picture was originally inserted is selected
sName = "Picture" & Target.Address
For Each oShape In Sh.Shapes
If oShape.Name = sName Then
If oShape.Visible = msoTrue Then
oShape.Visible = msoFalse
Else
oShape.Visible = msoTrue
End If
End If
Next
End Sub
None of my PM's or Sales team is able to utilize the sheet but others using 2010 can. If anyone can advise what I need to fix those using MS Office 2013 Excel (majority) & why our MAC users (very small group), it would be greatly apprecated
Bookmarks