Anzeige
Archiv - Navigation
636to640
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
636to640
636to640
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

wer kann mir helfen, Makro ändern!?!..danke

wer kann mir helfen, Makro ändern!?!..danke
12.07.2005 12:36:54
niki
Hallo geehrtes Forum,
Ich nütze das unten eingefügte Makro gern und oft um mappen eine inhaltsverzeichnis einzufügen...bei mappen bis 30 blätter sieht das sehr gut aus, nun hab ich eine mit fast 200 blättern, das ist nun nicht mehr passend.
Kann mir jemand den part des codes ändern, sodass sich die größe und die schrift der erzeugten buttons um 30% reduziert? (egal, einfach kleiner)
Ich habs schon versucht, aber ich kenn mich so gut wie nicht aus...
Oder gibts überhaupt ne bessere lösung für ein "elegantes" inhaltsverzeichnis?
Vielen dank an alle !
Sub Inhaltsverzeichnis()
Dim x As Integer, y As Integer, h As Integer, b As Integer, Btn As Object, _
sh As Integer, shp As Shape, c As Integer, wshInhalt As Worksheet
Application.ScreenUpdating = False
h = 25: b = 85: x = 60: y = 40
'alte Button löschen
If InhaltExists = False Then
Set wshInhalt = Worksheets.Add
With wshInhalt
.Move before:=Sheets(1)
.Name = "_Inhalt_"
End With
End If
Set wshInhalt = Worksheets("_Inhalt_")
On Error Resume Next
For Each shp In Sheets(1).Shapes
If shp.Name Like "btn_*" Then shp.Delete
Next shp
On Error GoTo 0
c = 1
'neue Buttons einfügen
'button für Aktualisierung
Set Btn = wshInhalt.Buttons.Add(0, 0, b, h)
With Btn
.Name = "btn_refresh"
.OnAction = "Inhaltsverzeichnis"
.Placement = xlFreeFloating
.PrintObject = False
.Characters.Text = "Auffrischen"
End With

For sh = 2 To Sheets.Count
Set Btn = wshInhalt.Buttons.Add(x, y, b, h)
With Btn
.Name = "btn_" & Format(sh, "000")
.OnAction = "activatesheet"
.Placement = xlFreeFloating
.PrintObject = True
.Characters.Text = Sheets(sh).Name
End With
'"Zurück"-Button löschen
On Error Resume Next
Sheets(sh).Shapes("btnBack").Delete
On Error GoTo 0
'"Zurück"-Button auf jedes Blatt
Set Btn = Sheets(sh).Buttons.Add(0, 0, 20, 15)
With Btn
.OnAction = "Back"
.Characters.Text = " .Placement = xlFreeFloating
.Name = "btnBack"
End With
' immer nur 10 Buttons untereinander
If c Mod 10 = 0 Then
x = x + b + 10
y = 40
c = 1
Else
y = y + h + 10
c = c + 1
End If
Next sh
wshInhalt.Range("A1").Select
Application.ScreenUpdating = True
End Sub

Private Sub ActivateSheet()
Dim shNum As Integer
shNum = CInt(Right(ActiveSheet.Shapes(Application.Caller).OLEFormat.Object.Name, 3))
Sheets(shNum).Select
End Sub


Private Sub back()
Sheets("_Inhalt_").Select
End Sub


Private Function InhaltExists() As Boolean
Dim iCounter As Integer
For iCounter = 1 To Worksheets.Count
If Worksheets(iCounter).Name = "_Inhalt_" Then
Worksheets(iCounter).Move before:=Sheets(1)
InhaltExists = True
Exit Function
End If
Next iCounter
InhaltExists = False
End Function

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: wer kann mir helfen, Makro ändern!?!..danke
12.07.2005 13:09:35
Uduuh
Hallo,

Sub Inhaltsverzeichnis()
Dim x As Integer, y As Integer, h As Integer, b As Integer, Btn As Object, _
sh As Integer, shp As Shape, c As Integer, wshInhalt As Worksheet
Application.ScreenUpdating = False
h = 18: b = 60: x = 30: y = 30
'alte Button löschen
If InhaltExists = False Then
Set wshInhalt = Worksheets.Add
With wshInhalt
.Move before:=Sheets(1)
.Name = "_Inhalt_"
End With
End If
Set wshInhalt = Worksheets("_Inhalt_")
On Error Resume Next
For Each shp In Sheets(1).Shapes
If shp.Name Like "btn_*" Then shp.Delete
Next shp
On Error GoTo 0
c = 1
'neue Buttons einfügen
'button für Aktualisierung
Set Btn = wshInhalt.Buttons.Add(0, 0, b, h)
With Btn
.Name = "btn_refresh"
.OnAction = "Inhaltsverzeichnis"
.Placement = xlFreeFloating
.PrintObject = False
.Characters.Text = "Auffrischen"
End With
For sh = 2 To Sheets.Count
Set Btn = wshInhalt.Buttons.Add(x, y, b, h)
With Btn
.Name = "btn_" & Format(sh, "000")
.OnAction = "activatesheet"
.Placement = xlFreeFloating
.PrintObject = True
.Characters.Text = Sheets(sh).Name
.Characters.Font.Size = 8
End With
'"Zurück"-Button löschen
On Error Resume Next
Sheets(sh).Shapes("btnBack").Delete
On Error GoTo 0
'"Zurück"-Button auf jedes Blatt
Set Btn = Sheets(sh).Buttons.Add(0, 0, 20, 15)
With Btn
.OnAction = "Back"
.Characters.Text = "<<"
.Placement = xlFreeFloating
.Name = "btnBack"
End With
' immer nur 10 Buttons untereinander
If c Mod 15 = 0 Then
x = x + b + 7
y = 30
c = 1
Else
y = y + h + 7
c = c + 1
End If
Next sh
wshInhalt.Range("A1").Select
Application.ScreenUpdating = True
End Sub

Gruß aus’m Pott
Udo

Anzeige
AW: wer kann mir helfen, Makro ändern!?!..danke
12.07.2005 13:15:48
Berber
Hallo,
'der Bereich in Deinem Code definiert die Höhe h und die Breite b für einen Teil der Buttons.
h = 25: b = 85: x = 60: y = 40
wenn Du Ihn entsprechend abänderst z.B. h = 17 b = 60
werden die Knöpfe kleiner.
zur Schriftgrösse und Art
'füge in die Bereiche mit den with Btn
folgendes ein:
.Font.Name = "Arial"
.Font.Size = 7
z.B.
For sh = 2 To Sheets.Count
Set Btn = wshInhalt.Buttons.Add(x, y, b, h)
With Btn
.Name = "btn_" & Format(sh, "000")
.OnAction = "activatesheet"
.Placement = xlFreeFloating
.PrintObject = True
.Characters.Text = Sheets(sh).Name
.Font.Name = "Arial"
.Font.Size = 7
End With
Gruss
Berber
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige