Thread: Error problems
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Nick Shinkins[_2_] Nick Shinkins[_2_] is offline
external usenet poster
 
Posts: 17
Default Error problems

Hiya I have this section of code which takes up to forty charts, identified
by references and pastes them into a word document.

I have an error handling statement which if the chart doesn't exist should
enable the procedure to recover and go on to the next chart.

I am testing the code by giving a reference to a chart that doesn't exist.
Unfortunately the code still crashes with an 1004 error, which I thought
would be trapped.

I do have another error handling code previously in the code but this should
be switched off when it reaches the code shown below.

Can anyone help? I can give more info if needed. Here is the code:


For ChartIdentifierNum = 1 To 40

ChartIdentifier = Sheets("Report Export Ref").Cells(3 +
ChartIdentifierNum, 5).Value
ChartReference = Sheets("Report Export Ref").Cells(3 +
ChartIdentifierNum, 6).Value

If ChartIdentifier < "" Then

If ChartReference < "" Then

Worksheets("Chart Sheet").Activate

On Error GoTo SkipChart
ActiveSheet.ChartObjects(ChartReference).Select

Selection.Copy

With wdApp
Set MyRange = .ActiveDocument.Content

MyRange.Find.Execute FindText:=ChartIdentifier, Forward:=True

If MyRange.Find.Found = True Then

MyRange.Select

.Selection.PasteSpecial Link:=False,
DataType:=wdPasteMetafilePicture, Placement:=wdInLine, DisplayAsIcon:=False

End If
End With

SkipChart:

On Error GoTo 0

End If

End If

Next ChartIdentifierNum


TIA!

A confused,

Nick Shinkins