I have been writing a fairly complex routine for MS Project. Long story short, whenever I try to access the filter property on a viewsingle object I receive a Run-time error '1101' (the argument is not valid). I can access every other property (whether it is present or not) both in immediate and in code.
The actual code is along lines of
If vS.Filter <> "" Then 'have a filter ..do stuff End if
The object model states that the .Filter property is Set/Get (and .Filter name is a string).
So, I am very confused - if anyone has come across this knows the answer it would be appreciated.
//Adding in the code fragment. I have fixed this for filters however, the same fix doesn't work for tables IF (and I suppose this could be the same for filters) the View has suffered some corruption and is missing a Table (or filter?) Object. I think that I will need to add an error checker for the runtime error - in this instance as can't seem to actually test for non-existence of a Get/Set Object property.
Dim v As View, vS As ViewSingle, vC As ViewCombination, pctDone As Single, lcount As Long Dim f As Filter, t As Table
For Each v In ThisProject.Views
lcount = lcount + 1
If v.Single Then 'Process Single views first
Set vS = ThisProject.ViewsSingle.Item(v.Name)
'Check for Resource type
Select Case True
Case v.Type = pjResourceItem
'check filter
Set f = vS.Filter
If f.Name <> "" Then 'have a filter
For lnglist = 1 To ColRFExPreview.Count
If f.Name = ColRFExPreview.Item(lnglist) Then
lngLbInd = lnglist - 1
f.Name = VTI_FRM.LB_ResFltrs.List(lngLbInd)
vS.Filter = f
End If
Next
End If
'check table (we will always check the table)
Set t = vS.Table
For lnglist = 1 To ColRTExPreview.Count
If t.Name = ColRTExPreview.Item(lnglist) Then
lngLbInd = lnglist - 1
t.Name = VTI_FRM.LB_ResTbles.List(lngLbInd)
vS.Table = t
End If
Next
Case Else 'Not a resource type
'check filter
Set f = vS.Filter
If f.Name <> "" Then 'have a filter
For lnglist = 1 To ColTFExPreview.Count
If f.Name = ColTFExPreview.Item(lnglist) Then
lngLbInd = lnglist - 1
f.Name = VTI_FRM.LB_FILTERS.List(lngLbInd)
vS.Filter = f
End If
Next
End If
'check table (we will always check the table)
Set t = vS.Table
For lnglist = 1 To ColTTExPreview.Count
If t.Name = ColTTExPreview.Item(lnglist) Then
lngLbInd = lnglist - 1
t.Name = VTI_FRM.LB_TABLES.List(lngLbInd)
vS.Table = t
End If
Next
End Select
Else 'Combination View - just need to check that Bottomview and topview need to change
Set vC = ThisProject.ViewsCombination(v.Name)
For lnglist = 1 To ColViewExPreview.Count
If vC.BottomView.Name = ColViewExPreview.Item(lnglist) Then
lngLbInd = lnglist - 1
vC.BottomView.Name = VTI_FRM.LB_Views.List(lngLbInd)
End If
If vC.TopView.Name = ColViewExPreview.Item(lnglist) Then
lngLbInd = lnglist - 1
vC.TopView.Name = VTI_FRM.LB_Views.List(lngLbInd)
End If
Next
End If