AlwaysNeedExcelHelp
New Member
- Joined
- Sep 24, 2019
- Messages
- 6
Hello all-
I have a userform which is taking pictures of graphs and displaying it in excel with the below code. Occasionally I get a Run Time Error 481 Invalid Picture on the line below. What's odd is when I go in and change the name of the charts in both the excel and the vba code, everything works smooth but every new excel instance causes this, any idea?
Sub Changechart(chartname As String)
Dim CurrentChart As Chart
Dim FName As String
FName = ThisWorkbook.Path & "\temp.bmp"
Set CurrentChart = ThisWorkbook.Sheets("Charts").ChartObjects(chartname).Chart
CurrentChart.Export Filename:=FName, filtername:="BMP"
frmCharts.imgChart.Picture = LoadPicture(FName)
End Sub
I have a userform which is taking pictures of graphs and displaying it in excel with the below code. Occasionally I get a Run Time Error 481 Invalid Picture on the line below. What's odd is when I go in and change the name of the charts in both the excel and the vba code, everything works smooth but every new excel instance causes this, any idea?
Sub Changechart(chartname As String)
Dim CurrentChart As Chart
Dim FName As String
FName = ThisWorkbook.Path & "\temp.bmp"
Set CurrentChart = ThisWorkbook.Sheets("Charts").ChartObjects(chartname).Chart
CurrentChart.Export Filename:=FName, filtername:="BMP"
frmCharts.imgChart.Picture = LoadPicture(FName)
End Sub