Displaying a chart from a worksheet on a userform

forneous

New Member
Joined
Feb 24, 2012
Messages
46
I am hoping someone can assist as I am not sure what is going wrong. I have a worksheet called "Reports" and on it I have one chart. I have a userform called "Reports" that I want to show the chart on. I am still a novice at VBA so I was getting some help with the coding. The code I have is;

Sub MyChart()
Dim currentchart As Chart
Dim fname As String

Set currentchart = Sheets("Reports").ChartObjects("Chart 1").Chart
fname = "G:\temp.gif"
currentchart.Export Filename:=fname, Filtername:="GIF"
Image1.Picture = LoadPicture(fname)
End Sub


Private Sub UserForm_Initialize()
Call MyChart
End Sub

When I try to run it I get Run-Time Error 76 Path Not Found and when I click ok, it takes me back to the code but nothing is highighted to show me where the error is occuring? Does anyone know why I am getting the error message?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,224,550
Messages
6,179,462
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top