Public Shared Function GetFileByName(ByVal name As String) As Document
Dim docIterator As DocumentSetIterator
docIterator = revitApp.Documents.GetEnumerator
Dim doc As Document = Nothing
While docIterator.MoveNext()
doc = docIterator.Current
If doc.Title.ToString = name Then
Return doc
End If
End While
Return (Nothing)
End Function
I recently had a live release failing on a user and after a bit of poking around I found that this code was returning nothing, but we knew that the document was open. It was failing because Revit wasn't returning the file extensions. It only happened on a couple of machines on this particular site, whereas others were fine. To my surprise it was because of the 'Hide extensions for known file types' user setting in Windows Explorer:
If (doc.Title.ToString = name) Or (doc.Title.ToString & ".rvt" = name) Then
