J
julia.stone
I am new to developing in VBA for Excel. I'd appreciate any tips on
how to fix this bug, as I believe I am on the right track but something
I can't quite see is incorrect. Thanks in advance.
I have a workbook with 7 sheets. Let's say on worksheet 5 there are 5
charts. On Worksheet 6 I have 5 option buttons, and for each button
that I select I want to display a particular chart. I have been able
to successfully loop through my chart objects and verify that I have 5,
yet when I try to export each of them I get the following error:
Run-time error '1004'
Application-defined or object-defined error
Below is my code sample of just trying to export one chart. The last
line of the code is where I get an error. Any help will be greatly
appreciated.
Private Sub OptionButton1_Click()
Dim strGifFileName As String
Dim CurrentChart As Chart
Dim index As Integer
index = 1
Set CurrentChart = Worksheets(6).ChartObjects(index).Chart
strGifFileName = "C:\My Documents\" & "MyChart" & index & ".gif"
CurrentChart.Export fileName:=strGifFileName, FilterName:="GIF"
End Sub
how to fix this bug, as I believe I am on the right track but something
I can't quite see is incorrect. Thanks in advance.
I have a workbook with 7 sheets. Let's say on worksheet 5 there are 5
charts. On Worksheet 6 I have 5 option buttons, and for each button
that I select I want to display a particular chart. I have been able
to successfully loop through my chart objects and verify that I have 5,
yet when I try to export each of them I get the following error:
Run-time error '1004'
Application-defined or object-defined error
Below is my code sample of just trying to export one chart. The last
line of the code is where I get an error. Any help will be greatly
appreciated.
Private Sub OptionButton1_Click()
Dim strGifFileName As String
Dim CurrentChart As Chart
Dim index As Integer
index = 1
Set CurrentChart = Worksheets(6).ChartObjects(index).Chart
strGifFileName = "C:\My Documents\" & "MyChart" & index & ".gif"
CurrentChart.Export fileName:=strGifFileName, FilterName:="GIF"
End Sub