bbao
asked on
How to add a picture using EXcel VBA on Mac?
hi Excel folks
i am looking for the right way to tell Excel VBA a pathname and show the picture given by the pathname.
please see attached the Excel Macro file for the simple macro - click a button to show a picture.
i don't know why the picture cannot be shown though the correct pathname has been hard-coded in the macro. the same issue applies to both High Sierra and Mojave, though i did see the picture shown under Mojave for once. just once and couldn't be reproduced.
another issue is, for some reasons the Shapes.AddPicture method doesn't work and report runtime error "104" when LinkToFile parameter is False.when LinkToFile is True, there is no runtime error but also no picture.
can anyone light me up?
thanks,
bbao
Book2.xlsm
i am looking for the right way to tell Excel VBA a pathname and show the picture given by the pathname.
please see attached the Excel Macro file for the simple macro - click a button to show a picture.
i don't know why the picture cannot be shown though the correct pathname has been hard-coded in the macro. the same issue applies to both High Sierra and Mojave, though i did see the picture shown under Mojave for once. just once and couldn't be reproduced.
another issue is, for some reasons the Shapes.AddPicture method doesn't work and report runtime error "104" when LinkToFile parameter is False.when LinkToFile is True, there is no runtime error but also no picture.
can anyone light me up?
thanks,
bbao
Book2.xlsm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@xtermie
thanks for your suggestion. i tried your code on my Mojave running Office 365, it still can't show the picture. see below the screenshot. i also tried below code but it does the same thing.
as indicated by the error message, i tried changing the full pathname to something not existing (such as "3.jpg") then i got below runtime error "1004".
not the thing becomes more interesting. the error message for a correct pathname suggests the file may have been moved, renamed or deleted. the error message for a really incorrect pathname tells you a runtime error code, then the debug mode shows the line with that pathname.
thanks for your suggestion. i tried your code on my Mojave running Office 365, it still can't show the picture. see below the screenshot. i also tried below code but it does the same thing.
With ActiveSheet.Pictures.Insert("/Users/dennis/Desktop/2.jpg")
.Left = 110
.Top = 220
.Width = 123
.Height = 134
End With
as indicated by the error message, i tried changing the full pathname to something not existing (such as "3.jpg") then i got below runtime error "1004".
not the thing becomes more interesting. the error message for a correct pathname suggests the file may have been moved, renamed or deleted. the error message for a really incorrect pathname tells you a runtime error code, then the debug mode shows the line with that pathname.
ASKER
@Eoin
you were right. i follow your instruction and Excel did show the pictures, always!
it seems to be a bug of Excel for years, as the issue applies to a number of early version of Excel for Mac. it seems to be a flag or switch somewhere in Excel runtime...
you were right. i follow your instruction and Excel did show the pictures, always!
it seems to be a bug of Excel for years, as the issue applies to a number of early version of Excel for Mac. it seems to be a flag or switch somewhere in Excel runtime...
ASKER
sorry for accepting the solution so late. thanks heaps again for all inputs.
ActiveSheet.Pictures.Inser
However, there is an add in that loads pictures in a mac which may help you (for free)
Check here
http://rwsoftware.weebly.com/loadpicture-for-mac.html