Attribute VB_Name = "FileDialog"
Option Explicit


' This example demonstrates the use of the FileDialog object.

Public Sub TestFileDialog()

    ' Reference to the FileDialog object.
    Dim objFileDialog As FileDialog
    Call ThisApplication.CreateFileDialog(objFileDialog)
    
    ' Definition of filter to select parts, assemblies, or any other file format.
    objFileDialog.filter = "Inventor Files (*.iam;*.ipt)|*.iam;*.ipt|All Files (*.*)|*.*"
    
    ' Definition of initial filter: part or assembly
    objFileDialog.FilterIndex = 1
    
    ' Window title.
    objFileDialog.DialogTitle = "File selection"
    
    ' Initial directory.
    objFileDialog.InitialDirectory = "C:\Temp"
        
    ' Initialize error mode to trap cancel button.
    objFileDialog.CancelError = True
    
    ' Display FileDialog object.  Procedure is the same to save a document.
    On Error Resume Next
    objFileDialog.ShowOpen
'    objFileDialog.ShowSave
    
    ' On error, window was cancelled.  Else, display file name.
    If Err Then
        MsgBox "Cancelled."
    ElseIf objFileDialog.Filename <> "" Then
        MsgBox "File " & objFileDialog.Filename & " was selected."
    End If
End Sub

 