Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
For a program im writing I want to check if a document exists or not then return the document object
which im doing with the following code
Friend Function SaveCopyOpen(Doc As Document, FileRoot As String, FileName As String,
_App As Inventor.Application, ByRef Exists As Boolean) As PartDocument
Dim NewDoc As PartDocument
With Doc
.DisplayName = FileName
Dim FullString = FileRoot & FileName & ".ipt"
Dim ExistinDoc As Document
Try
'Exists = System.IO.File.Exists(FileRoot) ' gonna try and see if this version works better and dosent throw a error message
'If Exists Then
' ExistinDoc = _App.Documents.Open(FileName)
' Return ExistinDoc
'End If
ExistinDoc = _App.Documents.Open(FileRoot) 'will throw a error here if part is already open
If ExistinDoc IsNot Nothing Then
Exists = True
Return ExistinDoc
End If
Catch ex As Exception
End Try
.SaveAs(FullString, True)
Exists = False
NewDoc = _App.Documents.Open(FullString)
End With
Return NewDoc
End Function
''' <summary>
It works however cause this window to pop up
is their any way around this
HII
Solved! Go to Solution.