psdich » 16.10.2007 (Вт) 13:34
Private Sub CommandButton1_Click()
'Application.Run "colpos"
If TextBox1.Text = "" Then
TextBox1.Value = 0
End If
Dim dia As Object
ActiveSheet.ChartObjects("diagram").Activate
' Charts("diagram").ChartGroups(1).Overlap = -50
Set dia = ActiveChart
Dim colcount As Integer
' dia.SeriesCollection(2).Select
colcount = dia.SeriesCollection(2).Points.Count
'MsgBox colcount
If TextBox1.Value < colcount Then
TextBox1.Value = TextBox1.Value + 1
Else
TextBox1.Value = 1
End If
ActiveSheet.Cells(1, 1).Select
Dim arr As Object
'ActiveSheet.Shapes("arrow").Select
Set arr = ActiveSheet.Shapes("arrow")
dia.ChartGroups(1).Overlap = 100
dia.ChartGroups(1).GapWidth = 200
' MsgBox dia.ChartArea.Width
'MsgBox dia.PlotArea.Width
Dim dialeft As Integer
dialeft = ActiveSheet.Shapes("diagram").Left + dia.ChartArea.Left + dia.PlotArea.Left
Dim colwidth As Single
colwidth = (dia.PlotArea.Width / colcount) / (dia.ChartGroups(1).GapWidth / 100 + 1)
Dim colBwidth As Single
colBwidth = colwidth * (dia.ChartGroups(1).GapWidth / 100)
'MsgBox colBwidth
Dim colN As Single
colN = TextBox1.Value
Dim colcenter As Single
colcenter = dialeft + colBwidth / 2 + colwidth / 2 + colBwidth * (colN - 1) + colwidth * (colN - 1)
Dim colleft As Single
colleft = dialeft + colBwidth / 2 + colBwidth * (colN - 1) + colwidth * (colN - 1)
Dim colright As Single
colright = dialeft + colBwidth / 2 + colwidth + colBwidth * (colN - 1) + colwidth * (colN - 1)
arr.Left = Round(colright, 0)
End Sub