Dave, I added the msgbox as you suggested and all macros appear to be called
correctly. I am really puzzled because they run correctly independent of the
toolbar, but it seems almost as if they are trying to run twice from the
toolbar. Since we can't isolate with part of the code, I have copied and
pasted the entire module below. Please note, this is my first serious work
with macros and I would consider myself to be a novice, though I learn well.
Here is the code (entirely) from my module - please see if you can help:
Option Explicit
Sub create_menubar()
Dim i As Long
Dim mac_names As Variant
Dim cap_names As Variant
Dim tip_text As Variant
'MsgBox ThisWorkbook.FullName
Call remove_menubar
mac_names = Array("Insert_Level2_Task()", _
"Insert_Level3_Task()", _
"Insert_Level4_Task()", _
"OpenCalendar")
cap_names = Array("Level 2 Task", _
"Level 3 Task", _
"Level 4 Task", _
"Calendar")
tip_text = Array("Insert Level 2 Task", _
"Insert Level 3 Task", _
"Insert Level 4 Task", _
"Select a Date")
With Application.CommandBars.Add
.Name = "Project Management"
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating
For i = LBound(mac_names) To UBound(mac_names)
With .Controls.Add(Type:=msoControlButton)
.OnAction = ThisWorkbook.Name & "!" & mac_names(i)
.Caption = cap_names(i)
.Style = msoButtonIconAndCaption
.FaceId = 0
.TooltipText = tip_text(i)
End With
Next i
End With
End Sub
Sub remove_menubar()
On Error Resume Next
Application.CommandBars("Project Management").Delete
On Error GoTo 0
End Sub
Sub OpenCalendar()
Calendar.Show
End Sub
Sub Insert_Level3_Task()
' Insert_Level3_Task Macro
' Click here to insert a level 3 task
Dim r As String
Dim length As Integer
Dim posit As Integer
Dim p As String
Dim res As Integer
'MsgBox ThisWorkbook.FullName
res = MsgBox("Insert Level 3 Task?", vbYesNo, "Insert New Task")
If res = vbYes Then
r = ActiveWindow.RangeSelection.Address
length = Len(r)
posit = InStr(1, r, ":")
p = Left(r, length - posit)
length = Len(p)
r = Right(p, length - 1)
Rows(ActiveWindow.RangeSelection.Address).Select
Selection.Insert Shift:=xlDown
Range(ActiveWindow.RangeSelection.Address).Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 2
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.Font.Italic = False
End With
Range("c" & r).Select
Selection.Font.Color = 255
ActiveCell.FormulaR1C1 = "new level 3 task"
Range("a1").Select
End If
End Sub
Sub Insert_Level2_Task()
' Insert_Level2_Task Macro
' Click here to insert a level 2 task
Dim r As String
Dim length As Integer
Dim posit As Integer
Dim p As String
Dim res As Integer
'MsgBox ThisWorkbook.FullName
res = MsgBox("Insert Level 2 Task?", vbYesNo, "Insert New Task")
If res = vbYes Then
r = ActiveWindow.RangeSelection.Address
length = Len(r)
posit = InStr(1, r, ":")
p = Left(r, length - posit)
length = Len(p)
r = Right(p, length - 1)
Rows(ActiveWindow.RangeSelection.Address).Select
Selection.Insert Shift:=xlDown
Range(ActiveWindow.RangeSelection.Address).Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 1
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.Font.Italic = True
End With
Range("c" & r).Select
Selection.Font.Color = 16711680
ActiveCell.FormulaR1C1 = "new level 2 task"
Range("a1").Select
End If
End Sub
Sub Insert_Level4_Task()
' Insert_Level4_Task Macro
' Click here to insert a level 4 task
Dim r As String
Dim length As Integer
Dim posit As Integer
Dim p As String
Dim res As Integer
'MsgBox ThisWorkbook.FullName
res = MsgBox("Insert Level 4 Task?", vbYesNo, "Insert New Task")
If res = vbYes Then
r = ActiveWindow.RangeSelection.Address
length = Len(r)
posit = InStr(1, r, ":")
p = Left(r, length - posit)
length = Len(p)
r = Right(p, length - 1)
Rows(ActiveWindow.RangeSelection.Address).Select
Selection.Insert Shift:=xlDown
Range(ActiveWindow.RangeSelection.Address).Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 3
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.Font.Italic = False
End With
Range("c" & r).Select
Selection.Font.Color = 255
ActiveCell.FormulaR1C1 = "new level 4 task"
Range("a1").Select
End If
End Sub
That's all of it besides the workbook commands you have for the toolbar.
I really appreciate your help.