run time 1004: the method 'applycustomtype' for object '_chart' fa

P

Peter T

FWIW my LanguageID is 1033 (even though Eng/Eng), perhaps something like
this -

Select case Application.LanguageSettings.LanguageID(msoLanguageIDInstall
Case 1033, 2057 ' lots more English codes
sTypeName = "Lines on 2 Axes" case 1031, 3079, 5127, 4103, 2055
sTypeName = "Linien auf zwei Achsen"
Case else: Msgbox "Language not supported"
End Select

If Len(sTypeName) = 0 Then
' Exit Sub ?
Else ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, _
TypeName:= sTypeName
End if

If you're only exchanging between one or two sites and the above always
works - fine. But keep in mind what Jon mentioned about multiple languages.
There's also another point he alluded to, it's generally safer to create
custom charts yourself, irrespective of language issues, rather than rely on
built in chart file always being available.

Regards,
Peter T

PS, just for my curiosity, I would be interested to know if the macro I
suggested will work for multiple languages, (subject the gallery file being
available)
http://tinyurl.com/yuwjxv

See post 5 in date view and please amend the typo (see follow-up post) so
that the test builtin typename is in English (not German as in the sub
Test), eg
sTypeName = "Line - Column on 2 Axes"
 
P

Peter T

A line feed went missing !
Select case Application.LanguageSettings.LanguageID(msoLanguageIDInstall
Case 1033, 2057 ' lots more English codes
sTypeName = "Lines on 2 Axes" case 1031, 3079, 5127, 4103, 2055
sTypeName = "Linien auf zwei Achsen"
Case else: Msgbox "Language not supported"
End Select

Case 1033, 2057 ' lots more English codes
sTypeName = "Lines on 2 Axes"
Case 1031, 3079, 5127, 4103, 2055
sTypeName = "Linien auf zwei Achsen"

Peter T
 
E

ewan7279

Hi Peter,

The solution works fine for now, but I will bear your suggestion in mind in
case it goes wrong...

Jon's suggestion to build the charts myself seems like a good idea, but the
solution only gave me a bar chart. To convert this to a line chart, Jon
suggested I use ActiveChart.ChartType = xlLine, but does this not prompt the
same problem by referring to a built-in chart type in English?

Cheers,
Ewan.
 
P

Peter T

Hi Ewan -
Jon's suggestion to build the charts myself seems like a good idea, but the
solution only gave me a bar chart. To convert this to a line chart, Jon
suggested I use ActiveChart.ChartType = xlLine, but does this not prompt the
same problem by referring to a built-in chart type in English?

I don't follow, that code is same as manually right-click on the chart area
ChartType etc, (can also apply different ChartType's to individual series)
and I don't think in any way related to language issues. Describe what the
problem is.

Regards,
Peter T
 
E

ewan7279

Hi Peter,

I have just altered the code again (as I had before) as such:

ActiveChart.ChartType = xlLineMarkers

'format and position chart
With ActiveChart
.SeriesCollection(2).AxisGroup = xlSecondary
.HasAxis(xlCategory, xlSecondary) = False
.HasAxis(xlValue, xlSecondary) = True
.HasTitle = True
.ChartTitle.Characters.Text = "Financials"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Total Direct Cost"
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = True
.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Direct Cost Per
Trade"
End With

This now works for the user, so i can only assume there must have been an
EBCAK (error between chair and keyboard).

Thanks for your input,
Ewan.
 
J

Jon Peltier

The built-in custom types have text names, but the standard types use
invariant constants to indicate type.

- Jon
 
J

Jon Peltier

xlLine is a numerical constant (value = 4) which has a name that looks like
text ("xlLine"). Chart type 4 is the same in all localizations of Excel.

- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top