K
Kevin
I have available to me a PDF coversion tool (adlib). I email my Excel
document and receive as a reply the PDF conversion. Works great...except for
some Excel charts that are created programatically. I've determined that if
I don't explicity declare certain parameters they get lost on their way to
the PDF, e.g., XValues as percent in Excel convert to general numbers in PDF.
I'm currently seeing plot areas resized and moved.
How would I alter the following code to explcitly declare the width and
height of the plot area? Thanks much. -Kevin
With ActiveSheet.ChartObjects.Add _
(Left:=intChartLeft%, Width:=intChartWidth%, Top:=intChartTop%,
Height:=intChartHeight%)
.Chart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:="Line -
Column on 2 Axes"
With .Chart.SeriesCollection.NewSeries
.Values = Series1Rng
.XValues = SeriesXValuesRng
.ChartType = xlColumnStacked
End With
With .Chart.SeriesCollection.NewSeries
.Values = Series2Rng
.ChartType = xlColumnStacked
End With
With .Chart.SeriesCollection.NewSeries
.Values = Series3Rng
.ChartType = xlColumnStacked
End With
With .Chart.SeriesCollection.NewSeries
.Values = Series4Rng
.ChartType = xlLineMarkers
.AxisGroup = 2
End With
.Chart.Location Where:=xlLocationAsObject, Name:=strChartLocation$
.Chart.HasLegend = True
.Chart.Legend.Position = xlBottom
.Chart.PlotArea.Width = intPlotAreaWidth%
.Chart.PlotArea.Height = intPlotAreaHeight%
.Chart.PlotArea.Left = intPlotAreaLeft%
.Chart.PlotArea.Top = intPlotAreaTop%
.Chart.PlotArea.Interior.ColorIndex = xlNone
.Chart.Axes(xlCategory, xlPrimary).HasTitle = True
.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Top = intXaxisTop%
.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Caption = strXaxisTitle$
.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Font.Name =
"Arial"
.Chart.Axes(xlCategory,
xlPrimary).AxisTitle.Characters.Font.FontStyle = "Bold"
.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Font.Size = 10
.Chart.Axes(xlCategory, xlPrimary).TickLabels.Alignment = xlCenter
.Chart.Axes(xlCategory, xlPrimary).TickLabels.Offset = 100
.Chart.Axes(xlCategory, xlPrimary).TickLabels.ReadingOrder = xlContext
.Chart.Axes(xlCategory, xlPrimary).TickLabels.Orientation = xlUpward
.Chart.Axes(xlCategory, xlPrimary).TickLabels.NumberFormat = "mmm-yy"
.Chart.Axes(xlValue, xlPrimary).HasTitle = True
.Chart.Axes(xlValue, xlPrimary).AxisTitle.Left = intLeftYaxisLeft%
.Chart.Axes(xlValue, xlPrimary).AxisTitle.Top = intLeftYaxisTop%
.Chart.Axes(xlValue, xlPrimary).MaximumScale = lngMaxScaleLeftAxis&
.Chart.Axes(xlValue, xlPrimary).MinimumScale = 0
.Chart.Axes(xlValue, xlPrimary).AxisTitle.Caption = strLeftYaxisTitle$
.Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Font.Name =
"Arial"
.Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Font.FontStyle
= "Bold"
.Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Font.Size = 10
.Chart.Axes(xlValue, xlSecondary).HasTitle = True
.Chart.Axes(xlValue, xlSecondary).AxisTitle.Left = intRightYaxisLeft%
.Chart.Axes(xlValue, xlSecondary).AxisTitle.Top = intRightYaxisTop%
.Chart.Axes(xlValue, xlSecondary).MaximumScale = sngMaxScaleRightAxis!
.Chart.Axes(xlValue, xlSecondary).MinimumScale = 0
If strRightYaxisTitle = "Cost" Then _
.Chart.Axes(xlValue, xlSecondary).TickLabels.NumberFormat =
"$#,##0"
If strRightYaxisTitle = "Percent" Then _
.Chart.Axes(xlValue, xlSecondary).TickLabels.NumberFormat = "0.0%"
.Chart.Axes(xlValue, xlSecondary).AxisTitle.Caption =
strRightYaxisTitle$
.Chart.Axes(xlValue, xlSecondary).AxisTitle.Characters.Font.Name =
"Arial"
.Chart.Axes(xlValue,
xlSecondary).AxisTitle.Characters.Font.FontStyle = "Bold"
.Chart.Axes(xlValue, xlSecondary).AxisTitle.Characters.Font.Size = 10
.Chart.SeriesCollection(1).Name = strSeries1Name$
.Chart.SeriesCollection(1).Border.Weight = xlThin
.Chart.SeriesCollection(1).Border.LineStyle = xlAutomatic
.Chart.SeriesCollection(1).Interior.ColorIndex = 18 '15
.Chart.SeriesCollection(1).Interior.Pattern = xlSolid
.Chart.SeriesCollection(2).Name = strSeries2Name$
.Chart.SeriesCollection(2).Border.Weight = xlThin
.Chart.SeriesCollection(2).Border.LineStyle = xlAutomatic
.Chart.SeriesCollection(2).Interior.ColorIndex = 17 '16
.Chart.SeriesCollection(2).Interior.Pattern = xlSolid
.Chart.SeriesCollection(3).Name = strSeries3Name$
.Chart.SeriesCollection(3).Border.Weight = xlThin
.Chart.SeriesCollection(3).Border.LineStyle = xlAutomatic
.Chart.SeriesCollection(3).Interior.ColorIndex = 19 '56
.Chart.SeriesCollection(3).Interior.Pattern = xlSolid
.Chart.SeriesCollection(4).Name = strSeries4Name$
.Chart.SeriesCollection(4).Border.ColorIndex = 1
.Chart.SeriesCollection(4).Border.Weight = xlThin
.Chart.SeriesCollection(4).Border.LineStyle = xlContinuous
.Chart.SeriesCollection(4).MarkerBackgroundColorIndex = 2
.Chart.SeriesCollection(4).MarkerForegroundColorIndex = 1
.Chart.SeriesCollection(4).MarkerStyle = xlTriangle
.Chart.SeriesCollection(4).MarkerSize = 5
.Chart.SeriesCollection(4).Trendlines.Add
.Chart.HasTitle = True
.Chart.ChartTitle.Characters.Text = strTitle$
End With
document and receive as a reply the PDF conversion. Works great...except for
some Excel charts that are created programatically. I've determined that if
I don't explicity declare certain parameters they get lost on their way to
the PDF, e.g., XValues as percent in Excel convert to general numbers in PDF.
I'm currently seeing plot areas resized and moved.
How would I alter the following code to explcitly declare the width and
height of the plot area? Thanks much. -Kevin
With ActiveSheet.ChartObjects.Add _
(Left:=intChartLeft%, Width:=intChartWidth%, Top:=intChartTop%,
Height:=intChartHeight%)
.Chart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:="Line -
Column on 2 Axes"
With .Chart.SeriesCollection.NewSeries
.Values = Series1Rng
.XValues = SeriesXValuesRng
.ChartType = xlColumnStacked
End With
With .Chart.SeriesCollection.NewSeries
.Values = Series2Rng
.ChartType = xlColumnStacked
End With
With .Chart.SeriesCollection.NewSeries
.Values = Series3Rng
.ChartType = xlColumnStacked
End With
With .Chart.SeriesCollection.NewSeries
.Values = Series4Rng
.ChartType = xlLineMarkers
.AxisGroup = 2
End With
.Chart.Location Where:=xlLocationAsObject, Name:=strChartLocation$
.Chart.HasLegend = True
.Chart.Legend.Position = xlBottom
.Chart.PlotArea.Width = intPlotAreaWidth%
.Chart.PlotArea.Height = intPlotAreaHeight%
.Chart.PlotArea.Left = intPlotAreaLeft%
.Chart.PlotArea.Top = intPlotAreaTop%
.Chart.PlotArea.Interior.ColorIndex = xlNone
.Chart.Axes(xlCategory, xlPrimary).HasTitle = True
.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Top = intXaxisTop%
.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Caption = strXaxisTitle$
.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Font.Name =
"Arial"
.Chart.Axes(xlCategory,
xlPrimary).AxisTitle.Characters.Font.FontStyle = "Bold"
.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Font.Size = 10
.Chart.Axes(xlCategory, xlPrimary).TickLabels.Alignment = xlCenter
.Chart.Axes(xlCategory, xlPrimary).TickLabels.Offset = 100
.Chart.Axes(xlCategory, xlPrimary).TickLabels.ReadingOrder = xlContext
.Chart.Axes(xlCategory, xlPrimary).TickLabels.Orientation = xlUpward
.Chart.Axes(xlCategory, xlPrimary).TickLabels.NumberFormat = "mmm-yy"
.Chart.Axes(xlValue, xlPrimary).HasTitle = True
.Chart.Axes(xlValue, xlPrimary).AxisTitle.Left = intLeftYaxisLeft%
.Chart.Axes(xlValue, xlPrimary).AxisTitle.Top = intLeftYaxisTop%
.Chart.Axes(xlValue, xlPrimary).MaximumScale = lngMaxScaleLeftAxis&
.Chart.Axes(xlValue, xlPrimary).MinimumScale = 0
.Chart.Axes(xlValue, xlPrimary).AxisTitle.Caption = strLeftYaxisTitle$
.Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Font.Name =
"Arial"
.Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Font.FontStyle
= "Bold"
.Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Font.Size = 10
.Chart.Axes(xlValue, xlSecondary).HasTitle = True
.Chart.Axes(xlValue, xlSecondary).AxisTitle.Left = intRightYaxisLeft%
.Chart.Axes(xlValue, xlSecondary).AxisTitle.Top = intRightYaxisTop%
.Chart.Axes(xlValue, xlSecondary).MaximumScale = sngMaxScaleRightAxis!
.Chart.Axes(xlValue, xlSecondary).MinimumScale = 0
If strRightYaxisTitle = "Cost" Then _
.Chart.Axes(xlValue, xlSecondary).TickLabels.NumberFormat =
"$#,##0"
If strRightYaxisTitle = "Percent" Then _
.Chart.Axes(xlValue, xlSecondary).TickLabels.NumberFormat = "0.0%"
.Chart.Axes(xlValue, xlSecondary).AxisTitle.Caption =
strRightYaxisTitle$
.Chart.Axes(xlValue, xlSecondary).AxisTitle.Characters.Font.Name =
"Arial"
.Chart.Axes(xlValue,
xlSecondary).AxisTitle.Characters.Font.FontStyle = "Bold"
.Chart.Axes(xlValue, xlSecondary).AxisTitle.Characters.Font.Size = 10
.Chart.SeriesCollection(1).Name = strSeries1Name$
.Chart.SeriesCollection(1).Border.Weight = xlThin
.Chart.SeriesCollection(1).Border.LineStyle = xlAutomatic
.Chart.SeriesCollection(1).Interior.ColorIndex = 18 '15
.Chart.SeriesCollection(1).Interior.Pattern = xlSolid
.Chart.SeriesCollection(2).Name = strSeries2Name$
.Chart.SeriesCollection(2).Border.Weight = xlThin
.Chart.SeriesCollection(2).Border.LineStyle = xlAutomatic
.Chart.SeriesCollection(2).Interior.ColorIndex = 17 '16
.Chart.SeriesCollection(2).Interior.Pattern = xlSolid
.Chart.SeriesCollection(3).Name = strSeries3Name$
.Chart.SeriesCollection(3).Border.Weight = xlThin
.Chart.SeriesCollection(3).Border.LineStyle = xlAutomatic
.Chart.SeriesCollection(3).Interior.ColorIndex = 19 '56
.Chart.SeriesCollection(3).Interior.Pattern = xlSolid
.Chart.SeriesCollection(4).Name = strSeries4Name$
.Chart.SeriesCollection(4).Border.ColorIndex = 1
.Chart.SeriesCollection(4).Border.Weight = xlThin
.Chart.SeriesCollection(4).Border.LineStyle = xlContinuous
.Chart.SeriesCollection(4).MarkerBackgroundColorIndex = 2
.Chart.SeriesCollection(4).MarkerForegroundColorIndex = 1
.Chart.SeriesCollection(4).MarkerStyle = xlTriangle
.Chart.SeriesCollection(4).MarkerSize = 5
.Chart.SeriesCollection(4).Trendlines.Add
.Chart.HasTitle = True
.Chart.ChartTitle.Characters.Text = strTitle$
End With