Minesh Babu
Minesh Babu

Reputation: 11

Problem with displaying graph in userform

I am trying to display an existing graph (Name: Chart 3) from Sheet3 to userform.

I used the below code, and it pops up error with debugging

Private Sub CommandButton1_Click()
Dim cchart As Chart
Dim fname As String


Set cchart = Sheets("Sheet3").ChartObjects("Chart 3").Chart
fname = "C:\CBS  Academic\Integrated Strategy Project\Final 
Paper\Temp\temp.gif"
cchart.Export Filename:=fname, filtername:="gif"
Image1.Picture = LoadPicture(fname)
End sub

Upvotes: 1

Views: 188

Answers (1)

Mikku
Mikku

Reputation: 6664

Try this: (Tested)

Private Sub CommandButton1_Click()

Dim cchart As Chart
Dim fname As String
Set cchart = Sheets("Sheet3").ChartObjects("Chart 3").Chart

fname = "C:\CBS  Academic\Integrated Strategy Project\FinalPaper\Temp\temp.gif" 'check the address again

cchart.Export Filename:=fname, filtername:="gif"
Image1.Picture = LoadPicture(fname)

End sub

Upvotes: 1

Related Questions