I have a macro that collects and loads various peices of data, before performing calculations. As part of the process I need to show the user a graph of the applied electrical load so that they can then make choices further down the line.
to do this, I generate a chart, save the image, and use loadPicture() to insert the image into an image object on the userform. On the mac this generates a "Sub or Function not defined" error for the LoadPicture() function
Here is my relevant code in the userform. LoadCurveChart is the name of the userform image object.
Private Sub DisplayLoadCurve()
Dim fName As String
Dim chtRng
Set chtRng = Sheet24.Range("AZ30:BD55")
fName = ThisWorkbook.Path & "\temp1.gif"
SaveChart fName, CreateChart(chtRng)
LoadCurveChart.Picture = LoadPicture(fName)
End Sub
Private Function CreateChart(ByVal chartRng As Range) As Chart
Dim cht As Object
Sheet24.Activate
chartRng.Select
With ActiveSheet
If .ChartObjects.count > 0 Then .ChartObjects.Delete
Set cht = .Shapes.AddChart2(240, xlXYScatterSmoothNoMarkers)
End With
With cht
.Chart.ChartTitle.Text = "Yearly Load Profile"
.Chart.SetSourceData Source:=chartRng
Set CreateChart = .Chart
End With
End Function
My search tells me that there is a general problem with LoadPicture() on Mac. If anyone has suggestions for fixes or alternatives, it would be greatly appreciated.
Note. This needs to run on other peoples computers, so any add-in requirements would need to be easy to install.
Thanks in advance
Bookmarks