Well I figured out everything and got it to work exactly as I need, and
without using cursor movements. Rod, I am now a beleiver in the fact that
it's best to NOT try to move the cursor in the script, as it's a much more
efficient set of code to do it without using the cursor. I wrote the script
in both options and it was much better to do it as listed below (Which I am
listing here just to close the door in this thread in case anyone else ever
is curious.)
There's probably some efficiencies that can be put into my code, but I am
happy with it as it is. Thanks again Rod!
Option Explicit
Private Sub UserForm_Initialize()
'Dim MyControl As Object
'Dim ControlsIndex As Integer
'Dim MyButtonLeft As Variant
'Dim MyButtonRight As Variant
OptionButton1.Value = True
'Macro that runs the first time the form opens
MyTextBox.Value = ""
MyTextBox.SetFocus
End Sub
Private Sub UserForm_Load()
'Macro that runs the first time the form opens
MyTextBox.Value = ""
MyButtonLeft.Value = 0
MyButtonRight.Value = 0
MyTextBox.SetFocus
End Sub
Private Sub RunMyMacro_Click()
Dim tskNewSummary As Task
Dim tskNewChild1 As Task
Dim tskNewChild2 As Task
Dim tskNewChild3 As Task
Dim tskNewChild4 As Task
If OptionButton1.Value = True Then
Set tskNewSummary = ActiveProject.Tasks.Add
Set tskNewChild1 = ActiveProject.Tasks.Add
Set tskNewChild2 = ActiveProject.Tasks.Add
Set tskNewChild3 = ActiveProject.Tasks.Add
Set tskNewChild4 = ActiveProject.Tasks.Add
tskNewSummary.Name = MyTextBox
tskNewSummary.OutlineLevel = "1"
tskNewChild1.OutlineLevel = "2"
tskNewChild2.OutlineLevel = "2"
tskNewChild3.OutlineLevel = "2"
tskNewChild4.OutlineLevel = "2"
tskNewChild1.Estimated = "No"
tskNewChild2.Estimated = "No"
tskNewChild3.Estimated = "No"
tskNewChild4.Estimated = "No"
tskNewChild1.Name = "Analysis for " & MyTextBox
tskNewChild2.Name = "Signoff for " & MyTextBox
tskNewChild3.Name = "Development for " & MyTextBox
tskNewChild4.Name = "QA for " & MyTextBox
tskNewChild1.ResourceNames = "Generic"
tskNewChild2.ResourceNames = "Generic"
tskNewChild3.ResourceNames = "Generic"
tskNewChild4.ResourceNames = "Generic"
'This procedure copies the Analyst to the summary row
SelectTaskField Row:=tskNewChild1.ID, RowRelative:=False,
Column:="Resource Names"
EditCopy
SelectTaskField Row:=tskNewSummary.ID, RowRelative:=False,
Column:="Text17"
EditPasteSpecial Link:=True, Type:=2, DisplayAsIcon:=False
'This procedure copies the Developer to the summary row
SelectTaskField Row:=tskNewChild3.ID, RowRelative:=False,
Column:="Resource Names"
EditCopy
SelectTaskField Row:=tskNewSummary.ID, RowRelative:=False,
Column:="Text18"
EditPasteSpecial Link:=True, Type:=2, DisplayAsIcon:=False
'This procedure copies the QA Engineer to the summary row
SelectTaskField Row:=tskNewChild4.ID, RowRelative:=False,
Column:="Resource Names"
EditCopy
SelectTaskField Row:=tskNewSummary.ID, RowRelative:=False,
Column:="Text19"
EditPasteSpecial Link:=True, Type:=2, DisplayAsIcon:=False
Else
Set tskNewSummary = ActiveProject.Tasks.Add
Set tskNewChild1 = ActiveProject.Tasks.Add
Set tskNewChild2 = ActiveProject.Tasks.Add
Set tskNewChild3 = ActiveProject.Tasks.Add
tskNewSummary.Name = MyTextBox
tskNewSummary.OutlineLevel = "1"
tskNewChild1.OutlineLevel = "2"
tskNewChild2.OutlineLevel = "2"
tskNewChild3.OutlineLevel = "2"
tskNewChild1.Estimated = "No"
tskNewChild2.Estimated = "No"
tskNewChild3.Estimated = "No"
tskNewChild1.Name = "Analysis for " & MyTextBox
tskNewChild2.Name = "Signoff for " & MyTextBox
tskNewChild3.Name = "Development/QA for " & MyTextBox
tskNewChild1.ResourceNames = "Generic"
tskNewChild2.ResourceNames = "Generic"
tskNewChild3.ResourceNames = "Generic"
'This procedure copies the Analyst to the summary row
SelectTaskField Row:=tskNewChild1.ID, RowRelative:=False,
Column:="Resource Names"
EditCopy
SelectTaskField Row:=tskNewSummary.ID, RowRelative:=False,
Column:="Text17"
EditPasteSpecial Link:=True, Type:=2, DisplayAsIcon:=False
'This procedure copies the Developer to the summary row
SelectTaskField Row:=tskNewChild3.ID, RowRelative:=False,
Column:="Resource Names"
EditCopy
SelectTaskField Row:=tskNewSummary.ID, RowRelative:=False,
Column:="Text18"
EditPasteSpecial Link:=True, Type:=2, DisplayAsIcon:=False
'This procedure copies the QA Engineer to the summary row
SelectTaskField Row:=tskNewChild3.ID, RowRelative:=False,
Column:="Resource Names"
EditCopy
SelectTaskField Row:=tskNewSummary.ID, RowRelative:=False,
Column:="Text19"
EditPasteSpecial Link:=True, Type:=2, DisplayAsIcon:=False
End If
MyUserForm.Hide
MyTextBox.Value = ""
MyTextBox.SetFocus
End Sub