mit folgendem Code erstelle ich für die Datei eine Symbolleiste Preisliste1, mit der ich neue Tabellen in der Datei einfüge.
Mit "Sheets.Add.Application.TemplatesPath" stelle ich den Vorlagen Path fest.
Ich habe den ausgeblendeten Code schon 4 Jahre unter Excel 97 benutzt. Jetzt wollte ich nur die Umstellung auf XP vornehmen.
Da unter XP der Path je Benutzer anders ist.
Setze ich nun einen Haltepunkt bei "Public Sub Roboter()" sehe ich das an diesem Punkt schon eine leere Tabelle eigefügt ist bevor die Tabelle Roboter eingefügt wird.
Ich habe keinen Ansatz warum. Kann mir jemand mal einen Tip geben.
Die anderen Module und Schalter, habe ich mal nicht gepostet, sehen ähnlich aus.
Ich habe den ausgeblendeten Code schon 4 Jahre unter Excel 97 benutzt. Jetzt wollte ich nur die Umstellung auf XP vornehmen.
Private Sub Workbook_Open() Private Sub Workbook_Deactivate() Private Sub Workbook_Activate() Private Sub Workbook_BeforeClose(Cancel As Boolean) Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range) ' in ein Modul Public Sub Roboter()
Code eingefügt mit Syntaxhighlighter 1.16
' In diese Arbeitsmappe
Option Explicit
Dim cb As CommandBar
Dim CBC As CommandBarButton
Dim I%
On Error Resume Next
Set cb = Application.CommandBars.Add(Name:="Preisliste1", _
temporary:=True, Position:=msoBarTop)
On Error GoTo 0
If Application.CommandBars("Preisliste1").Visible = False Then
cb.Visible = True
For I = 1 To 1
Set CBC = cb.Controls.Add(Type:=msoControlButton)
With CBC
.FaceId = 70 + I
.Width = 50 ' Breite der Schalter
.Style = msoButtonCaption ' Text auf Schaltfläche
Select Case I
Case 1
.Caption = "IRB"
.OnAction = "Roboter"
.TooltipText = "Roboter einfügen"
End Select
End With
Next I
End If
End Sub
On Error Resume Next
If Application.CommandBars("Preisliste1").Visible = True Then
Application.CommandBars("Preisliste1").Visible = False
End If
On Error GoTo 0
End Sub
On Error GoTo neu
If Application.CommandBars("Preisliste1").Visible = False Then
Application.CommandBars("Preisliste1").Visible = True
End If
On Error GoTo 0
Exit Sub
neu:
Workbook_Open
On Error GoTo 0
End Sub
On Error Resume Next
Application.CommandBars("Preisliste1").Delete
On Error GoTo 0
End Sub
On Error GoTo neu
If Application.CommandBars("Preisliste1").Visible = False Then
Application.CommandBars("Preisliste1").Visible = True
End If
Exit Sub
neu:
Workbook_Open
End Sub
Option Explicit
'Public Sub Roboter()
' If Application.UserName = "Klingner Eckhart" Or Application.UserName = "Doll Rüdiger" Then
' Sheets.Add Type:="C:\Programme\Microsoft Office\Vorlagen\Preisliste\Roboter.xlt"
' Else
'' Excelversion XP
' Sheets.Add Type:="C:\Dokumente und Einstellungen\Hajo_Zi.HAJO\Anwendungsdaten\Microsoft\Vorlagen\Preisliste\Roboter.xlt"
'' Excelversion 97
'' Sheets.Add Type:="C:\Programme\Microsoft Office\Vorlagen\Preisliste\Roboter.xlt"
' End If
'End Sub
Sheets.Add Type:=Sheets.Add.Application.TemplatesPath & "\Preisliste\Roboter.xlt"
End Sub
Gruß Hajo