Choose diagram

P

PB

Lars:
Why not to select chart directly? Much better. As an
example have my procedure, which sets the height and width
of the selected chart by input values. Selected can be the
same chart elements as you normally use. It is enabled by
means of Parent property. You can set analogous Chart
properties (.Axes etc.) in the same way.
PB

Sub ChartSize()
'Sets the dimensions of selected chart in mm
Dim ErrMsg As String, MB As Long
Const PointSize = 2.83, TMB = "Chart size"
On Error GoTo NoSelection
Set S = Selection.Parent
If S.Type <> -4169 Then ErrMsg = "No chart": GoTo ErrExit
ChartHeight = InputBox("Height /mm", TMB, 85)
If ChartHeight = "" Then Exit Sub
ChartWidth = InputBox("Width /mm", TMB, 100)
If ChartWidth = "" Then Exit Sub
ErrMsg = "Incorrect object"
On Error GoTo ErrExit
S.Parent.Height = ChartHeight * PointSize
S.Parent.Width = ChartWidth * PointSize
GoTo EndExit
NoSelection:
ErrMsg = "Nothing"
ErrExit:
MB = MsgBox(ErrMsg & " was selected", vbCritical, TMB)
EndExit:
On Error GoTo 0
End Sub
 

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