Hi Guys,
I'm trying to display the chart in userform using the code below which i found on net, but getting an error on red line below stating that the variable not set, any ideas why it is happening?
Any thoughts are welcome, thanks in advance.
Private Sub UserForm_Initialize()
Dim ChartNum As Integer
ChartNum = 1
UpdateChart
End sub
Private Sub UpdateChart()
Dim ChartNum As Integer
Set CurrentChart = Sheets("Data Collection").ChartObjects(ChartNum).Chart
CurrentChart.Parent.Width = 300
CurrentChart.Parent.Height = 150
' 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
Bookmarks