[Excel 2003] .Location of a chart
Hiya,
Does anyone know if there is a limit on the size of the tab name when trying to put a chart into a sheet. I have a sheet with 31 chars name, and it errors with invalid call/function. When I rename the sheet to 26 chars long, it runs fine...
Edit:
From Excel HElp:
Quote:
Location Method
See AlsoApplies ToExampleSpecificsMoves the chart to a new location. Chart object.
expression.Location(Where, Name)
expression Required. An expression that returns one of the objects in the Applies To list.
Where Required XlChartLocation. Where to move the chart.
XlChartLocation can be one of these XlChartLocation constants.
xlLocationAsNewSheet
xlLocationAsObject
xlLocationAutomatic
Name Optional Variant; required if Where is xlLocationAsObject. The name of the sheet where the chart will be embedded if Where is xlLocationAsObject or the name of the new sheet if Where is xlLocationAsNewSheet.
Example
This example moves the embedded chart to a new chart sheet named "Monthly Sales."
Worksheets(1).ChartObjects(1).Chart _
.Location xlLocationAsNewSheet, "Monthly Sales"
no mention of a naming limit...
Re: [Excel 2003] .Location of a chart
31 is correct
Can I see the exact code that you are trying to use?
Re: [Excel 2003] .Location of a chart
Code:
Set cht = objExcel.Charts.Add
With cht
.ChartType = IIf(blnLines, 65, 51) 'xlLineMarkers,xlColumnClustered
.SetSourceData Source:=sht.Range(sht.cells(lngStartRow, 1), sht.cells(lngRowOP, lngMaxCol + 1)), PlotBy:=1 'xlRows
If .SeriesCollection.Count > 1 Then
.SeriesCollection(1).Delete
End If 'since the days are numbers it considers it data hence adds a line - the code above removes that series...
Set rng = sht.Range(sht.cells(lngStartRow, 2), sht.cells(lngStartRow, lngMaxCol + 1))
For lngLoop = 1 To cht.SeriesCollection.Count
.SeriesCollection(lngLoop).XValues = "='" & sht.Name & "'!" & rng.Address(referencestyle:=-4150) 'xlr1c1
Next
.HasTitle = True
.ChartTitle.Characters.Text = strBrand & " - Daily " & strTitle & " (from " & IIf(blnUseLastUpdated, "last updated", "created") & ")"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Number of " & strYAxis
.HasLegend = True
.Legend.Position = IIf(blnLegendBottom, -4107, xlRight) 'xlbottom
.HasDataTable = False
'---- last thing - change the chart to an object!
.Location WHERE:=2, Name:=sht.Name 'xlLocationAsObject
End With
Something like that above
Name of the sheet shouldn't matter, just that it was 31 chars...