M
Mask
Hello Developers,
I work in Ms Project 2003 and 2007 using VB editor. I'm trying to add
a button to one bar. I created the bar and the button and they appear
when i launch project, but when i click it nothing happen.
At my Microsoft Project Object i have this code:
Private Sub Project_Open(ByVal pj As Project)
Dim myBar As CommandBar
Dim myButton As CommandBarButton
If myButton Is Nothing Then
Set myBar = CommandBars.Add(Name:="Export",
Position:=msoBarFloating, Temporary:=True)
myBar.Visible = True
Set myButton = myBar.Controls.Add(Type:=msoControlButton)
With myButton
.OnAction = "Export"
.Style = msoButtonCaption
.Caption = "Export to Excel"
End With
Else
myBar.Visible = True
End If
End Sub
And at my module:
Sub Export()
Project "Export to Excel"
End Sub
Sub Project(Action As String)
If Action = "Export to Excel" Then
< My Code >
End If
End Sub
I can't make it work. I read some things and I begin to wonder if i
need to Copy to Global Project some information. It doesn't make many
sense to me since "it's not correct" copy things to Global Project. If
I really need, how can i make it?
I will appreciate your help with this issue because my code works
without button but it is extremely important to Client having the
button for understandable reasons.
Best regards,
Mask
I work in Ms Project 2003 and 2007 using VB editor. I'm trying to add
a button to one bar. I created the bar and the button and they appear
when i launch project, but when i click it nothing happen.
At my Microsoft Project Object i have this code:
Private Sub Project_Open(ByVal pj As Project)
Dim myBar As CommandBar
Dim myButton As CommandBarButton
If myButton Is Nothing Then
Set myBar = CommandBars.Add(Name:="Export",
Position:=msoBarFloating, Temporary:=True)
myBar.Visible = True
Set myButton = myBar.Controls.Add(Type:=msoControlButton)
With myButton
.OnAction = "Export"
.Style = msoButtonCaption
.Caption = "Export to Excel"
End With
Else
myBar.Visible = True
End If
End Sub
And at my module:
Sub Export()
Project "Export to Excel"
End Sub
Sub Project(Action As String)
If Action = "Export to Excel" Then
< My Code >
End If
End Sub
I can't make it work. I read some things and I begin to wonder if i
need to Copy to Global Project some information. It doesn't make many
sense to me since "it's not correct" copy things to Global Project. If
I really need, how can i make it?
I will appreciate your help with this issue because my code works
without button but it is extremely important to Client having the
button for understandable reasons.
Best regards,
Mask