I have a spreadsheet with a user form displaying different graphs based on a combo box user selection. This is based on John Walkenbach's solution and uses this code.
Private Sub UpdateChart(ChartNum As Integer)
Dim currentchart As Chart, Fname As String
Set currentchart = Sheets("Portfolio").ChartObjects(ChartNum).Chart
currentchart.Parent.Width = 400
currentchart.Parent.Height = 200
' Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
currentchart.Export Filename:=Fname, FilterName:="GIF"
' Show the chart
Image1.Picture = LoadPicture(Fname)
End Sub
This works perfectly in Excel 2007, however when the same file is run in Excel 2010, I get frequent 'Runtime Error 481 Invalid Picture' errors.
Looking at Microsoft's site, there is a suggestion that I should use a BMP rather than a GIF file format (as this is a known Microsoft problem). Having amended the VBA accordingly, this made NO DIFFERENCE and the errors still happen.
I also came across a site suggesting a 'HotFix' using an updated version of a file called 'mscomctl.OCX'. Having tried this, again, it makes no difference.
I can save my file in Excel 2010, and reopen it in Excel 2007 and the errors don't occur.
Has anyone come across this problem and found a successful resolution.
Many thanks...
Bookmarks