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?
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?