Error from repeated chart copying
I have an application which repeatedly copies a chart to a new tab in a
workbook, then deletes the new copy after the user has finished. This works fine for a while but eventually an error results when the copy is attempted. No further charts can be created until the workbook is closed and re-opened. The number of successful copies seems to depend on the complexity of the workbook. For a complex workbook, 42 charts could be made before an error occurred. For a simpler workbook, 254 was the number. The error is reproducible: Make a new workbook and put a chart in it. Run the following code: Public Sub ChartCopyErrorTest() Application.DisplayAlerts = False Do On Error GoTo printerr ActiveWorkbook.Sheets("Chart1").Copy Befo=ActiveWorkbook.Sheets("Sheet1") On Error GoTo 0 a$ = "This is chart number " & Format(i%) ActiveChart.Name = a$ ActiveChart.Delete DoEvents i% = i% + 1 Loop While i% < 1000 printerr: MsgBox "Bombed after making this many charts: " & Format(i%) End Sub On my machine, the number displayed is 254. Version of Excel is 2002 (10.6789.6811) SP3. Has anyone else seen this problem, and more importantly, know of a workaround? -- Pat Wiegand Ridgewood Visionware |
Error from repeated chart copying
Check out this link...
http://support.microsoft.com/default...84&Product=xlw -- HTH... Jim Thomlinson "Pat Wiegand" wrote: I have an application which repeatedly copies a chart to a new tab in a workbook, then deletes the new copy after the user has finished. This works fine for a while but eventually an error results when the copy is attempted. No further charts can be created until the workbook is closed and re-opened. The number of successful copies seems to depend on the complexity of the workbook. For a complex workbook, 42 charts could be made before an error occurred. For a simpler workbook, 254 was the number. The error is reproducible: Make a new workbook and put a chart in it. Run the following code: Public Sub ChartCopyErrorTest() Application.DisplayAlerts = False Do On Error GoTo printerr ActiveWorkbook.Sheets("Chart1").Copy Befo=ActiveWorkbook.Sheets("Sheet1") On Error GoTo 0 a$ = "This is chart number " & Format(i%) ActiveChart.Name = a$ ActiveChart.Delete DoEvents i% = i% + 1 Loop While i% < 1000 printerr: MsgBox "Bombed after making this many charts: " & Format(i%) End Sub On my machine, the number displayed is 254. Version of Excel is 2002 (10.6789.6811) SP3. Has anyone else seen this problem, and more importantly, know of a workaround? -- Pat Wiegand Ridgewood Visionware |
Error from repeated chart copying
Thanks, Jim -- exactly the link I needed. You're awsome!
-- Pat Wiegand Ridgewood Visionware "Jim Thomlinson" wrote: Check out this link... http://support.microsoft.com/default...84&Product=xlw -- HTH... Jim Thomlinson "Pat Wiegand" wrote: I have an application which repeatedly copies a chart to a new tab in a workbook, then deletes the new copy after the user has finished. This works fine for a while but eventually an error results when the copy is attempted. No further charts can be created until the workbook is closed and re-opened. The number of successful copies seems to depend on the complexity of the workbook. For a complex workbook, 42 charts could be made before an error occurred. For a simpler workbook, 254 was the number. The error is reproducible: Make a new workbook and put a chart in it. Run the following code: Public Sub ChartCopyErrorTest() Application.DisplayAlerts = False Do On Error GoTo printerr ActiveWorkbook.Sheets("Chart1").Copy Befo=ActiveWorkbook.Sheets("Sheet1") On Error GoTo 0 a$ = "This is chart number " & Format(i%) ActiveChart.Name = a$ ActiveChart.Delete DoEvents i% = i% + 1 Loop While i% < 1000 printerr: MsgBox "Bombed after making this many charts: " & Format(i%) End Sub On my machine, the number displayed is 254. Version of Excel is 2002 (10.6789.6811) SP3. Has anyone else seen this problem, and more importantly, know of a workaround? -- Pat Wiegand Ridgewood Visionware |
All times are GMT +1. The time now is 12:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com