October 17, 2018
I've got something that doesn't work like it should
Public Function Picture_2_File(myImage As Variant) As String
Dim Ans As String, sPath As String
Dim rng As Range
Dim oCht As ChartObject
Dim oPic As Object
On Error Resume Next
Kill ThisWorkbook.Path & "\Temp.gif"
Set oPic = ThisWorkbook.Worksheets("INTRO").Shapes(myImage)
sPath = ThisWorkbook.Path & "\Temp.gif"
Set oCht = ActiveSheet.ChartObjects.Add(100, 0, oPic.Width, oPic.Height)
Set oCht = Nothing
On Error GoTo 0
Picture_2_File = sPath
The worksheet where the images are stored is named "INTRO" and i've got pictures
myImgae will contain the picture name of the one that I want to create as image file to import in a Userform (I chose for gif as extension but the same happens with jpg or bmp)
If I run the code the temp.gif is created but the content is blank
If I run the macro and interupt it at the before tha Paste command is exceuted and then go though it step by step (F8) it works and the temp.gif is the picture.
I tried adding a wait state (more than one) but that doesn't make it work.
Any suggestions? I'm using Excel 2021 and the worksheets are unportected etc etc.
Thanks in advance
November 1, 2018