Hi,Hi !
Seems a bad logic …
But first, in which line error occurs ?‼
Explain the code purpose …
Hi Georgia ,
Resolving this problem is so easy if the workbook with the code is uploaded ; debugging an error , especially a Run Time Error is that much more difficult , since a lot of RTEs can be due to the data.
A lot of time will be spent in various members making suggestions which you will either confirm or reject.
This particular error has so many reasons , one of which can be the chart name ; can you say what is the value of the variable l when this error occurs i.e. does this error occur in the first pass through the For loop or is it after some iterations through the loop ?
What does the variable ChartName contain when the error occurs ? Does this chart exist in the worksheet ?
Narayan
Does the VB error message give any other details? (Syntax, Subscript, Object undefined, etc.)
Just curious, can you try copying the entire chart object, not just the chart?
Code:exo_wsheet.ChartObjects(ChartName).CopyPicture Appearance:=xlScreen, Format:=xlPicture
Dim ch As Chart
Set ch = exo_wsheet.ChartObjects(ChartName).Chart
'Debug info
MsgBox "Sheet is: " & exo_wsheet.Name
MsgBox "Chart Object is: " & ChartName
MsgBox "Chart Item is: " & ch.Name
ch.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
Hmm. Okay, trying to debug. Can you replace the problem line with this
and let us know what the 3 messages say, if anything unusualCode:Dim ch As Chart Set ch = exo_wsheet.ChartObjects(ChartName).Chart 'Debug info MsgBox "Sheet is: " & exo_wsheet.Name MsgBox "Chart Object is: " & ChartName MsgBox "Chart Item is: " & ch.Name ch.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
Ok...so 6 of the charts are able to get copied correctly, but then errors out on 7th? When it crashes, can you hover your cursor over the CHartName variable, and see what is displayed. Is there someway perhaps the VB is getting a bad name?
Could be...sounds like we're on a right track. How many rows are in this table?
Is there maybe an extra blank row that is causing problems? Or something odd?Code:For Each exo_listrow_cht In config.ListObjects("chart_list2").ListRows
For Each exo_listrow_cht In config.ListObjects("chart_list2").ListRows
ChartNo = exo_listrow_cht.Range.Cells(1, exo_listcol_cht("Chart_No").Index).Value
ChartName = exo_listrow_cht.Range.Cells(1, exo_listcol_cht("Chart_name").Index).Value
ChartField = "chart_tbl16"
'=============
'NEW LINE HERE
'=============
If ChartName = "" Then GoTo SkipRow
Set exo_listcol_fld = config.ListObjects(ChartField).ListColumns
l = l + 1
Set ppo_slide = ppo_pres.Slides.AddSlide(ppo_app.ActivePresentation.Slides.Count + 1, ppo_ctpl)
exo_wsheet.ChartObjects(ChartName).Chart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
ppo_app.ActivePresentation.Slides(l).Shapes.Paste
For Each exo_listrow_fld In config.ListObjects(ChartField).ListRows
'exo_wsheet.Range(exo_listrow_fld.Range.Cells(1, exo_listcol_fld("rangename").Index).Value).CopyPicture Appearance:=xlScreen, Format:=xlPicture
exo_wsheet.Range(exo_listrow_fld.Range.Cells(1, exo_listcol_fld("rangename").Index).Value).Copy
ppo_slide.Select
i = ppo_app.ActivePresentation.Slides(l).Shapes.Count
ppo_app.ActivePresentation.Slides(l).Shapes.PasteSpecial , , , , , msoTrue
'ppo_app.ActivePresentation.Slides(l).Shapes.Paste
Set ppo_shape = ppo_app.ActivePresentation.Slides(l).Shapes(i + 1)
Application.CutCopyMode = False 'clear the clipboard
ppo_shape.Name = exo_listrow_fld.Range.Cells(1, exo_listcol_fld("ShapeName").Index)
ppo_shape.Top = exo_listrow_fld.Range.Cells(1, exo_listcol_fld("top").Index)
ppo_shape.Left = exo_listrow_fld.Range.Cells(1, exo_listcol_fld("left").Index)
Next
'BOUNCES TO HERE
SkipRow:
Next