Warum funktioniert "Chartobjects.Select"nicht?
das ist mein gesamter code
Option Explicit
Private Sub ScrollBar()
Dim ScrollBar As String
Dim chartname As String
Dim a, a1 As Integer
Dim b, b1 As Integer
Dim x1 As Integer
Dim x2 As Integer
Dim nMaxZeilen As Integer
Dim NewFileName() As String
Dim Min As Double
Dim Max As Double
Dim Chart As String
Dim sheetname As String
Chart = "Chart 1"
Dim Counter As Integer
Dim nMaxZeilen2 As String
Dim varname1, varname2 As String
varname1 = "scrolmin"
varname2 = "scrolmax"
Dim chtobj As ChartObject
Dim Msg As String
Dim n As Integer
Dim ws As Worksheet
Dim iiii As Integer
Dim cht_width As Integer
Dim cht_height As Integer
Dim Top_Position As Integer
Dim Left_Position As Integer
Dim k As Integer
iiii = 1
For Each ws In ActiveWorkbook.Worksheets
n = ws.Chartobjects.Count
'Msg = "Chart List for Sheet " & vbTab & ws.Name & vbTab & _
' "No charts = " & n & vbCrLf & vbCrLf
'Msg = Msg & "Name " & vbTab & vbTab & "Index" & vbTab & "Top Pos" & _
' vbTab & "Left Pos " & vbTab & "Width " & vbTab & "Height" & vbCrLf
Do While k <= n
k = k + 1
Chartobjects.Select
ActiveSheet.ChartObject(1).Active
Counter = 1
chartname = ActiveChart.Name
If chartname = "" Then 'überarbeiten weil ich es nicht nochmal machen will ... rest morgen... *gg*
MsgBox "Kein Diagrammm ausgewählt!!!"
Else
NewFileName = Split(chartname, " ")
sheetname = NewFileName(0)
chartname = NewFileName(1) & " " & NewFileName(2)
End If
If Counter = Empty Then
MsgBox "incorrect!!!"
Exit Sub
End If
Chart = Chart & Counter
If Not ActiveChart.Name = "" Then
Range("a:a").Select
nMaxZeilen = ActiveSheet.UsedRange.Rows.Count
nMaxZeilen2 = nMaxZeilen
Range("a" & nMaxZeilen + 1) = "=min(a4:a" & nMaxZeilen & ")"
a = Range("a" & nMaxZeilen + 1)
Range("a" & nMaxZeilen + 1).Delete
ActiveSheet.ScrollBars.Add(60, 50, 450, 20).Name = varname1
ActiveSheet.ScrollBars(varname1).Select
With Selection 'von min bis x1
.value = Range("II1") ' = variable durch schieber definiert!!!
.Min = a ' = a
.Max = b ' = x2
.SmallChange = 1
.LargeChange = 10
.LinkedCell = "$II$1"
.Display3DShading = True
End With
ActiveSheet.ScrollBars.Add(60, 70, 450, 20).Name = varname2
ActiveSheet.ScrollBars(varname2).Select
With Selection
.value = Range("II2")
.Min = a
.Max = b
.SmallChange = 1
.LargeChange = 10
.LinkedCell = "$II$2"
.Display3DShading = True
End With
a = Range("II1")
b = Range("II2")
ActiveSheet.Chartobjects(chartname).Activate
With ActiveChart.Axes(xlCategory)
.MinimumScale = a '=a
.MaximumScale = b '=b
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
.HasTitle = True
.AxisTitle.Characters.Text = "Time"
End With
Else
MsgBox "kein Chart ausgewählt!!!"
End If
For Each chtobj In ActiveSheet.Chartobjects
cht_width = chtobj.Width
cht_height = chtobj.Height
Top_Position = chtobj.Top
Left_Position = chtobj.Left
iiii = iiii + 1
Loop
Next 'chtobj
Next 'ws
'out = MsgBox(Msg, , "Chart List")
End Sub
vielen dank im vorraus
das ist mein gesamter code
Option Explicit
Private Sub ScrollBar()
Dim ScrollBar As String
Dim chartname As String
Dim a, a1 As Integer
Dim b, b1 As Integer
Dim x1 As Integer
Dim x2 As Integer
Dim nMaxZeilen As Integer
Dim NewFileName() As String
Dim Min As Double
Dim Max As Double
Dim Chart As String
Dim sheetname As String
Chart = "Chart 1"
Dim Counter As Integer
Dim nMaxZeilen2 As String
Dim varname1, varname2 As String
varname1 = "scrolmin"
varname2 = "scrolmax"
Dim chtobj As ChartObject
Dim Msg As String
Dim n As Integer
Dim ws As Worksheet
Dim iiii As Integer
Dim cht_width As Integer
Dim cht_height As Integer
Dim Top_Position As Integer
Dim Left_Position As Integer
Dim k As Integer
iiii = 1
For Each ws In ActiveWorkbook.Worksheets
n = ws.Chartobjects.Count
'Msg = "Chart List for Sheet " & vbTab & ws.Name & vbTab & _
' "No charts = " & n & vbCrLf & vbCrLf
'Msg = Msg & "Name " & vbTab & vbTab & "Index" & vbTab & "Top Pos" & _
' vbTab & "Left Pos " & vbTab & "Width " & vbTab & "Height" & vbCrLf
Do While k <= n
k = k + 1
Chartobjects.Select
ActiveSheet.ChartObject(1).Active
Counter = 1
chartname = ActiveChart.Name
If chartname = "" Then 'überarbeiten weil ich es nicht nochmal machen will ... rest morgen... *gg*
MsgBox "Kein Diagrammm ausgewählt!!!"
Else
NewFileName = Split(chartname, " ")
sheetname = NewFileName(0)
chartname = NewFileName(1) & " " & NewFileName(2)
End If
If Counter = Empty Then
MsgBox "incorrect!!!"
Exit Sub
End If
Chart = Chart & Counter
If Not ActiveChart.Name = "" Then
Range("a:a").Select
nMaxZeilen = ActiveSheet.UsedRange.Rows.Count
nMaxZeilen2 = nMaxZeilen
Range("a" & nMaxZeilen + 1) = "=min(a4:a" & nMaxZeilen & ")"
a = Range("a" & nMaxZeilen + 1)
Range("a" & nMaxZeilen + 1).Delete
ActiveSheet.ScrollBars.Add(60, 50, 450, 20).Name = varname1
ActiveSheet.ScrollBars(varname1).Select
With Selection 'von min bis x1
.value = Range("II1") ' = variable durch schieber definiert!!!
.Min = a ' = a
.Max = b ' = x2
.SmallChange = 1
.LargeChange = 10
.LinkedCell = "$II$1"
.Display3DShading = True
End With
ActiveSheet.ScrollBars.Add(60, 70, 450, 20).Name = varname2
ActiveSheet.ScrollBars(varname2).Select
With Selection
.value = Range("II2")
.Min = a
.Max = b
.SmallChange = 1
.LargeChange = 10
.LinkedCell = "$II$2"
.Display3DShading = True
End With
a = Range("II1")
b = Range("II2")
ActiveSheet.Chartobjects(chartname).Activate
With ActiveChart.Axes(xlCategory)
.MinimumScale = a '=a
.MaximumScale = b '=b
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
.HasTitle = True
.AxisTitle.Characters.Text = "Time
End With
Else
MsgBox "kein Chart ausgewählt!!!"
End If
For Each chtobj In ActiveSheet.Chartobjects
cht_width = chtobj.Width
cht_height = chtobj.Height
Top_Position = chtobj.Top
Left_Position = chtobj.Left
iiii = iiii + 1
Loop
Next 'chtobj
Next 'ws
'out = MsgBox(Msg, , "Chart List")
End Sub
vielen dank im vorraus