View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Runtime Error '1004' Method 'ActiveChart' of Object '_Global' failed

Without recreating your code I don't think it's necessary to select anything
other than to do the ExecuteExcel4Macro, which can normally be done a
different way -

(untested)

With objRptWS.Shapes(strBox1).
.Drawingobject.formula = "=$A$1"
With .Textframe
'etc

or (subject to no puctuation type characters in the name)
With objRptWS.Texboxes(strBox1).
.formula = "=$A$1"
With .Shaperange.Textframe


For Each objChart In objRptWS.ChartObjects
If StrComp(objChart.NAME, "Chart 1") < 0 Then
objChart.Axes(xlCategory).TickLabels.Orientation = 90
End If
Next objChart

re "xlCategory", you'd need a reference to Excel to access the named
constants

Regards,
Peter T

wrote in message
oups.com...
I've read many similar posts on this subject but it seems this error
can have many different causes. I've created an Access DB that
generates Excel reports (Requirement). It happens on every other
report (Same rpt) beginning with the second one, it only corrects
itself though if press 'END' when the error message comes up. I've
noticed a symptom that tells me this error is going to occur and I
close the Excel file before it finishs and gets to the code that causes
the error. Below is the indication I'm going to get the error:


objRptWS.Activate
objRptWS.Range(objRptWS.Cells(5, 20), objRptWS.Cells(5,
21)).Select
With .Shapes(strBox1).TextFrame
.Characters.Text = " "
objRptWS.Shapes(strBox1).Select
ExecuteExcel4Macro "FORMULA(" & strJudge1 & ")"
.Characters.Font.Size = 12
.Characters.Font.NAME = "ToyotaKV"
.Characters.Font.Bold = True
.HorizontalAlignment = xlHAlignCenter
End With

Every other time is when it kind of skips the ExecuteExcel4Macro line
and does put the formula into the box. This is the indication however
the error happens later on in the code (The code itself is pretty long
so just including snippets if anyone needs more of the code to help me
please let me know). That code is:

For Each objChart In objRptWS.ChartObjects
If StrComp(objChart.NAME, "Chart 1") < 0 Then
objRptWS.ChartObjects(objChart.NAME).Activate
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.Orientation = 90
Set objChart = Nothing
End If
Next objChart

The ActiveChart statement is the one the debugger highlights as the
culprit. Any help would be greatly appreciated