Hi, this is actually an Excel question but I believe a great deal of the programming is the same as Access..... I'm generating a graph in a spreadsheet. (using the handy dandy record macro function... it writes code for me...) The graph must be resized to fit the format of the page and when it is selected, the reference is ("Chart 1") or ("Chart 2")... or something like that. Each time I test my code.... the number increments and crashes the macro. sooooo can someone tell how to either...
1) Generate the graph with handwritten code or
2) reset the chart count at the beginning of the macro.
Just let me know if you need more info or if the code snippet is not helpful
---------------------------------------
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 3/3/2003 by pabowlin
'
'
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Sheet2").Range("A1:M4"), PlotBy:= _
xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:="Charts"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "PC Team Members Trained"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
'here is where I manipulate the chart to fit the page
ActiveSheet.Shapes("Chart 4").IncrementLeft 158.25
ActiveSheet.Shapes("Chart 4").IncrementTop -104.25
ActiveSheet.Shapes("Chart 4").ScaleWidth 0.65, msoFalse, msoScaleFromTopLeft
ActiveSheet.Shapes("Chart 4").ScaleHeight 0.51, msoFalse, msoScaleFromTopLeft
End Sub
1) Generate the graph with handwritten code or
2) reset the chart count at the beginning of the macro.
Just let me know if you need more info or if the code snippet is not helpful
---------------------------------------
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 3/3/2003 by pabowlin
'
'
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Sheet2").Range("A1:M4"), PlotBy:= _
xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:="Charts"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "PC Team Members Trained"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
'here is where I manipulate the chart to fit the page
ActiveSheet.Shapes("Chart 4").IncrementLeft 158.25
ActiveSheet.Shapes("Chart 4").IncrementTop -104.25
ActiveSheet.Shapes("Chart 4").ScaleWidth 0.65, msoFalse, msoScaleFromTopLeft
ActiveSheet.Shapes("Chart 4").ScaleHeight 0.51, msoFalse, msoScaleFromTopLeft
End Sub