如何在MS project中排除vba代码的某些行
我已经在task中为update Preference编写了代码,并且成功了。 例如,由线切割、edm和cmm工艺组成的新任务,它可以自动更新先前任务。但只是为了一些任务,我不想更新它的前身。 我想添加这个,除了unique id=2,3我应该在哪里添加代码。 这是我的密码如何在MS project中排除vba代码的某些行,vba,ms-project,Vba,Ms Project,我已经在task中为update Preference编写了代码,并且成功了。 例如,由线切割、edm和cmm工艺组成的新任务,它可以自动更新先前任务。但只是为了一些任务,我不想更新它的前身。 我想添加这个,除了unique id=2,3我应该在哪里添加代码。 这是我的密码 Sub AutoPredecessorRepairLevel3() Dim TA As Task Dim TB As Task For Each TA In ActiveProject.Tasks
Sub AutoPredecessorRepairLevel3()
Dim TA As Task
Dim TB As Task
For Each TA In ActiveProject.Tasks
If (TA.Name Like "*report*") Then
For Each TB In TA.OutlineParent.OutlineChildren
If (TB.Name Like "*fitting*") Or (TB.Name Like "*cmm*") Or (TB.Name Like "*polishing*") Or (TB.Name Like "*edm*") Or (TB.Name Like "*wire cut*") Or (TB.Name Like "*el milling*") Or (TB.Name Like "*milling el*") Then
TA.LinkPredecessors Tasks:=TB
End If
Next TB
End If
If (TA.Name Like "*fitting*") Then
For Each TB In TA.OutlineParent.OutlineChildren
If (TB.Name Like "*cmm*") Or (TB.Name Like "*polishing*") Or (TB.Name Like "*edm*") Or (TB.Name Like "*wire cut*") Or (TB.Name Like "*el milling*") Or (TB.Name Like "*milling el*") Then
TA.LinkPredecessors Tasks:=TB
End If
Next TB
End If
If (TA.Name Like "*cmm*") Then
For Each TB In TA.OutlineParent.OutlineChildren
If (TB.Name Like "*polishing*") Or (TB.Name Like "*edm*") Or (TB.Name Like "*wire cut*") Or (TB.Name Like "*el milling*") Or (TB.Name Like "*milling el*") Then
TA.LinkPredecessors Tasks:=TB
End If
Next TB
End If
If (TA.Name Like "*polishing*") Then
For Each TB In TA.OutlineParent.OutlineChildren
If (TB.Name Like "*edm*") Or (TB.Name Like "*wire cut*") Or (TB.Name Like "*el milling*") Or (TB.Name Like "*milling el*") Then
TA.LinkPredecessors Tasks:=TB
End If
Next TB
End If
If (TA.Name Like "*edm*") Then
For Each TB In TA.OutlineParent.OutlineChildren
If (TB.Name Like "*wire cut*") Or (TB.Name Like "*el milling*") Or (TB.Name Like "*milling el*") Then
TA.LinkPredecessors Tasks:=TB
End If
Next TB
End If
If (TA.Name Like "*el milling*") Or (TA.Name Like "*milling el*") Then
For Each TB In TA.OutlineParent.OutlineChildren
If (TB.Name Like "*el design*") Or (TB.Name Like "*design el*") Then
TA.LinkPredecessors Tasks:=TB
End If
Next TB
End If
If (TA.Name Like "*wire cut*") And Not TA.Name = "cam wire cut" Then
For Each TB In TA.OutlineParent.OutlineChildren
If (TB.Name Like "*cam wire cut*") Or (TB.Name Like "*cam wire*") Then
TA.LinkPredecessors Tasks:=TB
End If
Next TB
End If
Next TA
使用Not(TA.UniqueID=2或TA.UniqueID=3)
和其他测试跳过UniqueID=2或3的任务:
Sub AutoPredecessorRepairLevel3()
Dim TA As Task
Dim TB As Task
For Each TA In ActiveProject.Tasks
If Not (TA.UniqueID = 2 Or TA.UniqueID = 3) And (TA.Name Like "*report*") Then
For Each TB In TA.OutlineParent.OutlineChildren
If Not (TB.UniqueID = 2 Or TB.UniqueID = 3) And ((TB.Name Like "*fitting*") Or (TB.Name Like "*cmm*") Or (TB.Name Like "*polishing*") Or (TB.Name Like "*edm*") Or (TB.Name Like "*wire cut*") Or (TB.Name Like "*el milling*") Or (TB.Name Like "*milling el*")) Then
TA.LinkPredecessors Tasks:=TB
End If
Next TB
End If
'....
Next TA
End Sub
我不确定你在问什么。。。但是你也可以使用
而不是<代码>如果不是(TA.Name如“*report*”),则执行相反的操作。您还可以使用Select Case
执行类似的操作。。。