Hallo Leute
Ich habe ein Problem mit einer durch VB erzeugten Menüleiste.
Der code wurde für MSProject 2003 geschrieben und er funktioniert hier problemlos!!
Jetzt habe ich auf 2007 umgestellt und nun wird die Menüleiste zwar immer noch aufgerufen aber beim klick auf einen Button wird das VB-Makro nicht mehr ausgeführt.
Hoffe ihr könnt mir weiterhelfen.
Gruß Nils
Ich habe ein Problem mit einer durch VB erzeugten Menüleiste.
Der code wurde für MSProject 2003 geschrieben und er funktioniert hier problemlos!!
Jetzt habe ich auf 2007 umgestellt und nun wird die Menüleiste zwar immer noch aufgerufen aber beim klick auf einen Button wird das VB-Makro nicht mehr ausgeführt.
Hoffe ihr könnt mir weiterhelfen.
Gruß Nils
Code:
Option Explicit
Sub AddAmecoBarManual()
Call DeleteAmecoBar(ThisProject)
Call AddAmecoBar(ThisProject)
End Sub
Sub AddAmecoBar(pj)
' Dim GetEngPrDtBtn As CommandButton, GetCaptyDtBtn As CommandButton
' Dim RefrEngPrDtBtn As CommandBarButton, ExportReportBtn As CommandButton
Dim GetEngPrDtBtn, GetCaptyDtBtn, RefrEngPrDtBtn, ExportReportBtn
Dim cbar1 As CommandBar
On Error GoTo AddBar
If pj.CommandBars("Ameco").Enabled Then
pj.CommandBars("Ameco").Visible = True
Exit Sub
'instead of exiting you can also delete the bar and add it again
'(command buttons may be missing...)
' pj.CommandBars("Ameco").Delete
' GoTo AddBar
' 'MsgBox "deleted"
End If
Exit Sub
AddBar:
If ActiveProject = VBAProject.ThisProject Then
Set cbar1 = pj.CommandBars.Add(Name:="Ameco", Position:=msoBarBottom)
cbar1.Visible = True
'Use CommandBars(index), where index is the name or index number of a command bar,
'to return a single CommandBar object. The following example docks the toolbar
'named "Ameco" at the bottom of the application window.
'CommandBars("Ameco").Position = msoBarBottom 'msoBarFloating
Set GetEngPrDtBtn = pj.CommandBars("Ameco").Controls.Add(Type:=msoControlButton, temporary:=True)
GetEngPrDtBtn.Caption = "Get Engine Project Data - "
GetEngPrDtBtn.Style = msoButtonCaption
On Error Resume Next
GetEngPrDtBtn.OnAction = "SubProjImportHandling"
Set GetCaptyDtBtn = pj.CommandBars("Ameco").Controls.Add(Type:=msoControlButton, temporary:=True)
GetCaptyDtBtn.Caption = "Get Capacity Data - "
GetCaptyDtBtn.Style = msoButtonCaption
On Error Resume Next
GetCaptyDtBtn.OnAction = "!<GetCapacityData>"
Set RefrEngPrDtBtn = pj.CommandBars("Ameco").Controls.Add(Type:=msoControlButton, temporary:=True)
RefrEngPrDtBtn.Caption = "Refresh Engine Project Data - "
RefrEngPrDtBtn.Style = msoButtonCaption
On Error Resume Next
RefrEngPrDtBtn.OnAction = "RefreshSubProjectData"
Set ExportReportBtn = pj.CommandBars("Ameco").Controls.Add(Type:=msoControlButton, temporary:=True)
ExportReportBtn.Caption = "Export Excel Report"
ExportReportBtn.Style = msoButtonCaption
On Error Resume Next
ExportReportBtn.OnAction = "ExportBiweeklyReport"
End If
Exit Sub
ExitProcedure:
On Error Resume Next
'Cleanup code for the procedure goes here
Exit Sub
GetEngPrDtBtn_ErrorHandler:
MsgBox "GetEngPrDtBtn_ErrorHandler", vbCritical
Resume Next
End Sub
Sub DeleteAmecoBar(pj)
On Error Resume Next
If pj.CommandBars("Ameco").Enabled Then
pj.CommandBars("Ameco").Delete
End If
End Sub