Compile error: Method or Data member not found

MyBlackStar

New Member
Joined
Jul 3, 2009
Messages
10
This macro is part of the Pertmaster Risk Expert Application: It was not created by me nore modified by me, it is part of the PertMaster Risk Expert Software:

I am trying to run the Convert Lags To Tasks Macro Ver. 1.3 but i keep getting the following Error Message: Compile error: Method or Data member not found

Would Anyone Be So kind to help me resolve this issue because i am not very apt with VBA scrip and trouble shooting this sort of issues.

Here is the list of the codes for the macro: I have not change any codes from the original pertmaster file.


****** http-equiv="Content-Type" content="text/html; charset=utf-8">****** name="ProgId" content="Word.Document">****** name="Generator" content="Microsoft Word 11">****** name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CJOSERA%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> Option Explicit<o:p></o:p>
<o:p> </o:p>
Private m_dtTimeNow As Date<o:p></o:p>
<o:p> </o:p>
Private Sub cmdCancel_Click()<o:p></o:p>
Unload Me<o:p></o:p>
End Sub<o:p></o:p>
<o:p> </o:p>
Private Sub cmdOK_Click()<o:p></o:p>
<o:p> </o:p>
Dim nCount As Long<o:p></o:p>
Dim objTask As Task<o:p></o:p>
Dim objLink As Link<o:p></o:p>
<o:p></o:p>
'Checks if the txtLag field contains a numeric values<o:p></o:p>
If Not IsNumeric(txtLag) Then<o:p></o:p>
MsgBox "The lag duration value is not a valid number."<o:p></o:p>
txtLag.SetFocus<o:p></o:p>
Exit Sub<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
'This macro does not convert negative lags<o:p></o:p>
If Not txtLag.Value >= 0 Then<o:p></o:p>
MsgBox "The lag duration value cannot be a negative value."<o:p></o:p>
txtLag.SetFocus<o:p></o:p>
Exit Sub<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
' check that the correlation value is in range<o:p></o:p>
If chkCorrelate Then<o:p></o:p>
If Not IsNumeric(txtCorr.Value) Then<o:p></o:p>
MsgBox "The Correlation value is not a valid number"<o:p></o:p>
txtCorr.SetFocus<o:p></o:p>
Exit Sub<o:p></o:p>
End If<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
' add the links as required<o:p></o:p>
nCount = 0<o:p></o:p>
<o:p></o:p>
MouseWaitPointer True<o:p></o:p>
<o:p></o:p>
ActivePlan.Windows.AutoRefresh = False<o:p></o:p>
ActivePlan.AutoTimeAnalyse = False<o:p></o:p>
<o:p></o:p>
m_dtTimeNow = ActivePlan.SummaryInfo.TimeNow<o:p></o:p>
<o:p></o:p>
For Each objTask In ActivePlan.Tasks<o:p></o:p>
<o:p></o:p>
For Each objLink In objTask.Links.Succeeding<o:p></o:p>
<o:p></o:p>
If ShouldAddLag(objTask, objLink) = True Then<o:p></o:p>
AddLinkTask objTask, objLink<o:p></o:p>
nCount = nCount + 1<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
Next 'objLink<o:p></o:p>
Next 'objTask<o:p></o:p>
<o:p></o:p>
ActivePlan.EmptyUndoList<o:p></o:p>
ActivePlan.AutoTimeAnalyse = False<o:p></o:p>
ActivePlan.TimeAnalyse<o:p></o:p>
ActivePlan.Windows.AutoRefresh = True<o:p></o:p>
<o:p></o:p>
MsgBox nCount & " lags converted to tasks"<o:p></o:p>
<o:p></o:p>
SaveModuleSetting REGISTRY_MODULE_NAME, REIGSTRY_SECTION, "txtLag", txtLag.Value<o:p></o:p>
SaveModuleSetting REGISTRY_MODULE_NAME, REIGSTRY_SECTION, "chkSuccRisk", chkSuccRisk.Value<o:p></o:p>
SaveModuleSetting REGISTRY_MODULE_NAME, REIGSTRY_SECTION, "chkCorrelate", chkCorrelate.Value<o:p></o:p>
SaveModuleSetting REGISTRY_MODULE_NAME, REIGSTRY_SECTION, "txtCorr", txtCorr.Value<o:p></o:p>
SaveModuleSetting REGISTRY_MODULE_NAME, REIGSTRY_SECTION, "chkLagsUnderSummary", chkLagsUnderSummary.Value<o:p></o:p>
<o:p></o:p>
Unload Me<o:p></o:p>
<o:p></o:p>
MouseWaitPointer False<o:p></o:p>
<o:p></o:p>
End Sub<o:p></o:p>
<o:p> </o:p>
Private Function ShouldAddLag(objTask As Task, objLink As Link) As Boolean<o:p></o:p>
'Checks if lag should be converted to a task<o:p></o:p>
<o:p> </o:p>
ShouldAddLag = False<o:p></o:p>
<o:p> </o:p>
Dim objSucTask As Task<o:p></o:p>
Set objSucTask = objLink.Task<o:p></o:p>
<o:p> </o:p>
'is lag greater than or eqaul to the specified value<o:p></o:p>
If objLink.Lag >= txtLag.Value Then<o:p></o:p>
<o:p> </o:p>
'has the successor started<o:p></o:p>
If objLink.LinkType = eltFinishToStart Or objLink.LinkType = eltStartToStart Then<o:p></o:p>
<o:p></o:p>
If objSucTask.Dates.ActualStart > 0 Then<o:p></o:p>
Exit Function<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
ElseIf objLink.LinkType = eltFinishToFinish Or objLink.LinkType = eltStartToFinish Then<o:p></o:p>
<o:p></o:p>
If objSucTask.Dates.ActualFinish > 0 Then<o:p></o:p>
Exit Function<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
End If<o:p></o:p>
<o:p> </o:p>
ShouldAddLag = True<o:p></o:p>
<o:p></o:p>
End If<o:p></o:p>
<o:p> </o:p>
End Function<o:p></o:p>
<o:p> </o:p>
Private Sub AddLinkTask(objTask As Task, objLink As Link)<o:p></o:p>
'Converts lag into a task and replaces lag with link<o:p></o:p>
<o:p></o:p>
Dim objLinkTask As Task<o:p></o:p>
Dim objSummaryTask As Task<o:p></o:p>
Dim objTaskRiskDist As RiskDistribution<o:p></o:p>
Dim objLagRiskDist As RiskDistribution<o:p></o:p>
Dim fRatio As Double<o:p></o:p>
Dim fltRemainingPercent As Double<o:p></o:p>
Dim nDaysDone As Long<o:p></o:p>
Dim nRDUR As Long<o:p></o:p>
<o:p></o:p>
Set objLinkTask = ActivePlan.Tasks.Add<o:p></o:p>
objLinkTask.Name = GetLinkType(objLink) & objTask.Name & ":" & objLink.Task.Name<o:p></o:p>
<o:p></o:p>
objLinkTask.RemainingDuration = objLink.Lag<o:p></o:p>
objLinkTask.Description = "Lag Task"<o:p></o:p>
<o:p></o:p>
'link the new task in<o:p></o:p>
If objLink.LinkType = eltFinishToStart Then<o:p></o:p>
<o:p></o:p>
objLinkTask.Links.Preceding.Add objTask.Name, eltFinishToStart<o:p></o:p>
objLinkTask.Links.Succeeding.Add objLink.Task.Name, eltFinishToStart<o:p></o:p>
<o:p></o:p>
Set objTaskRiskDist = objTask.RiskRemainingDuration(eroaReturnOnlyIfExists)<o:p></o:p>
<o:p></o:p>
nRDUR = objTask.RemainingDuration<o:p></o:p>
<o:p></o:p>
ElseIf objLink.LinkType = eltStartToStart Then<o:p></o:p>
<o:p></o:p>
objLinkTask.Links.Preceding.Add objTask.Name, eltStartToStart<o:p></o:p>
objLinkTask.Links.Succeeding.Add objLink.Task.Name, eltFinishToStart<o:p></o:p>
<o:p></o:p>
Set objTaskRiskDist = objLink.Task.RiskRemainingDuration(eroaReturnOnlyIfExists)<o:p></o:p>
<o:p></o:p>
nRDUR = objLink.Task.RemainingDuration<o:p></o:p>
<o:p></o:p>
ElseIf objLink.LinkType = eltFinishToFinish Then<o:p></o:p>
<o:p></o:p>
objLinkTask.Links.Preceding.Add objTask.Name, eltFinishToStart<o:p></o:p>
objLinkTask.Links.Succeeding.Add objLink.Task.Name, eltFinishToFinish<o:p></o:p>
<o:p></o:p>
Set objTaskRiskDist = objTask.RiskRemainingDuration(eroaReturnOnlyIfExists)<o:p></o:p>
<o:p></o:p>
nRDUR = objTask.RemainingDuration<o:p></o:p>
<o:p></o:p>
ElseIf objLink.LinkType = eltStartToFinish Then<o:p></o:p>
<o:p></o:p>
objLinkTask.Links.Preceding.Add objTask.Name, eltStartToStart<o:p></o:p>
objLinkTask.Links.Succeeding.Add objLink.Task.Name, eltFinishToFinish<o:p></o:p>
<o:p></o:p>
Set objTaskRiskDist = objLink.Task.RiskRemainingDuration(eroaReturnOnlyIfExists)<o:p></o:p>
nRDUR = objLink.Task.RemainingDuration<o:p></o:p>
<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
'set the linktask calendar<o:p></o:p>
If objLink.LinkType = eltStartToFinish Or objLink.LinkType = eltStartToStart Then<o:p></o:p>
Set objLinkTask.Calendar = objTask.Calendar<o:p></o:p>
Else<o:p></o:p>
Set objLinkTask.Calendar = objLink.Task.Calendar<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
'Set the linkTask Actual start if task has already started<o:p></o:p>
If objLink.LinkType = eltStartToFinish Or objLink.LinkType = eltStartToStart Then<o:p></o:p>
<o:p></o:p>
If objTask.Dates.ActualStart > 0 Then<o:p></o:p>
objLinkTask.Dates.ActualStart = objTask.Dates.ActualStart<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
ElseIf objLink.LinkType = eltFinishToStart Or objLink.LinkType = eltFinishToFinish Then<o:p></o:p>
<o:p></o:p>
If objTask.Dates.ActualFinish > 0 Then<o:p></o:p>
objLinkTask.Dates.ActualStart = objTask.Dates.ActualFinish<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
If objLinkTask.Dates.ActualStart > 0 Then<o:p></o:p>
<o:p></o:p>
objLinkTask.OriginalDuration = objLink.Lag<o:p></o:p>
nDaysDone = objTask.GetWorkingTime(objTask.Dates.ActualStart, ActivePlan.SummaryInfo.TimeNow, ewdStartTimeToStartTime)<o:p></o:p>
<o:p></o:p>
If objLink.Lag > nDaysDone Then<o:p></o:p>
objLinkTask.RemainingDuration = objLink.Lag - nDaysDone<o:p></o:p>
Else<o:p></o:p>
objLinkTask.RemainingDuration = 0<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
If chkSuccRisk.Value = True Then<o:p></o:p>
' Set objTaskRiskDist = objLink.Task.RiskRemainingDuration(eroaReturnOnlyIfExists)<o:p></o:p>
<o:p></o:p>
If Not objTaskRiskDist Is Nothing Then<o:p></o:p>
<o:p></o:p>
Set objLagRiskDist = objLinkTask.RiskRemainingDuration(eroaCreateIfNotExist)<o:p></o:p>
<o:p></o:p>
fRatio = objTaskRiskDist.Min / nRDUR<o:p></o:p>
objLagRiskDist.Min = objLinkTask.RemainingDuration * fRatio<o:p></o:p>
<o:p></o:p>
fRatio = objTaskRiskDist.MostLikely / nRDUR<o:p></o:p>
objLagRiskDist.MostLikely = objLinkTask.RemainingDuration * fRatio<o:p></o:p>
<o:p></o:p>
fRatio = objTaskRiskDist.Max / nRDUR<o:p></o:p>
objLagRiskDist.Max = objLinkTask.RemainingDuration * fRatio<o:p></o:p>
<o:p></o:p>
If chkCorrelate.Value = True And txtCorr.Value > "" Then<o:p></o:p>
<o:p></o:p>
Set objLagRiskDist.CorrelationParentRisk = objTaskRiskDist<o:p></o:p>
<o:p></o:p>
objLagRiskDist.CorrelationPercentage = txtCorr.Value<o:p></o:p>
<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
End If<o:p></o:p>
End If<o:p></o:p>
<o:p> </o:p>
On Error Resume Next<o:p></o:p>
<o:p> </o:p>
'Stores the new tasks representing lags under a summary level<o:p></o:p>
If chkLagsUnderSummary Then<o:p></o:p>
<o:p></o:p>
Set objSummaryTask = ActivePlan.Tasks("LAGTASKS")<o:p></o:p>
<o:p></o:p>
If objSummaryTask Is Nothing Then<o:p></o:p>
Set objSummaryTask = ActivePlan.Tasks.Add<o:p></o:p>
objSummaryTask.Name = "LAGTASKS"<o:p></o:p>
objSummaryTask.Description = "Lag Tasks"<o:p></o:p>
objSummaryTask.Style.TextAttributes.BackgroundColor = 255<o:p></o:p>
End If<o:p></o:p>
<o:p> </o:p>
Set objLinkTask.ParentTask = objSummaryTask<o:p></o:p>
<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
objLink.Lag = 0<o:p></o:p>
<o:p> </o:p>
End Sub<o:p></o:p>
<o:p> </o:p>
Private Function GetLinkType(objLink As Link) As String<o:p></o:p>
<o:p> </o:p>
'assume FS unless proved otherwise<o:p></o:p>
GetLinkType = "FS_"<o:p></o:p>
<o:p></o:p>
If objLink.LinkType = eltStartToStart Then<o:p></o:p>
GetLinkType = "SS_"<o:p></o:p>
ElseIf objLink.LinkType = eltFinishToFinish Then<o:p></o:p>
GetLinkType = "FF_"<o:p></o:p>
ElseIf objLink.LinkType = eltStartToFinish Then<o:p></o:p>
GetLinkType = "SF_"<o:p></o:p>
End If<o:p></o:p>
<o:p> </o:p>
End Function<o:p></o:p>
<o:p> </o:p>
Private Sub chkCorrelate_Click()<o:p></o:p>
txtCorr.Enabled = chkCorrelate.Value<o:p></o:p>
End Sub<o:p></o:p>
<o:p> </o:p>
Private Sub chkSuccRisk_Click()<o:p></o:p>
<o:p></o:p>
chkCorrelate.Enabled = chkSuccRisk.Value<o:p></o:p>
<o:p></o:p>
If chkCorrelate.Enabled And chkCorrelate.Value Then<o:p></o:p>
txtCorr.Enabled = True<o:p></o:p>
Else<o:p></o:p>
txtCorr.Enabled = False<o:p></o:p>
End If<o:p></o:p>
<o:p> </o:p>
End Sub<o:p></o:p>
<o:p> </o:p>
Private Sub txtCorr_Change()<o:p></o:p>
<o:p> </o:p>
If txtCorr.Value = "" And chkCorrelate.Value Then<o:p></o:p>
chkCorrelate.Value = False<o:p></o:p>
txtCorr.Enabled = False<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
End Sub<o:p></o:p>
<o:p> </o:p>
Private Sub UserForm_Initialize()<o:p></o:p>
<o:p> </o:p>
chkSuccRisk_Click<o:p></o:p>
txtLag = GetModuleSetting(REGISTRY_MODULE_NAME, REIGSTRY_SECTION, "txtLag", "20")<o:p></o:p>
chkSuccRisk.Value = GetModuleSetting(REGISTRY_MODULE_NAME, REIGSTRY_SECTION, "chkSuccRisk", "False")<o:p></o:p>
chkCorrelate.Value = GetModuleSetting(REGISTRY_MODULE_NAME, REIGSTRY_SECTION, "chkCorrelate", "False")<o:p></o:p>
txtCorr = GetModuleSetting(REGISTRY_MODULE_NAME, REIGSTRY_SECTION, "txtCorr", "100")<o:p></o:p>
chkLagsUnderSummary.Value = GetModuleSetting(REGISTRY_MODULE_NAME, REIGSTRY_SECTION, "chkLagsUnderSummary", "False")<o:p></o:p>
chkSuccRisk_Click<o:p></o:p>
<o:p> </o:p>
End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
which line of the code gives you an error? it should highlight the line after you click debug.
 
Upvote 0
Try using "Application.ScreenUpdating = False" instead of that line. Scroll a little way down you will see "ActivePlan.Windows.AutoRefresh = True", replace that with "Application.ScreenUpdating = True" Hope that works for you.
 
Upvote 0
yeah i try that it didn't work. What should i do...It tells me the same error message for the codes you sent...thanks again help...Would you know anything else to try
 
Upvote 0
What if you just delete those two lines? Take out ActivePlan.Window.AutoRefresh = True/False" lines and try running the macro
 
Upvote 0
Oh Man, I did that and now i am getting the same message for this now?

m_dtTimeNow = ActivePlan.SummaryInfo.TimeNow

what do you think is wrong...
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,652
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top