Create File Dialog with 'Open from vault' capability using VBA

Create File Dialog with 'Open from vault' capability using VBA

rcolon9E4ZX
Advocate Advocate
1,272 Views
1 Reply
Message 1 of 2

Create File Dialog with 'Open from vault' capability using VBA

rcolon9E4ZX
Advocate
Advocate

Hey guys,

 

I developed a program for the company I work for to export a formatted bill of materials from an Inventor assembly file. Currently, I have a 'Use active assembly' option and also a 'Browse for file' option. Unfortunately, when you browse for assemblies, the file dialog can only look for local files. In the program, I current use Application.FileDialog(msoFileDialogFilePicker) for creating the file dialog. I recently found a chunk of code that launches an Open file dialog that looks exactly like the one you get when pressing Open from the GUI. The only problem is that the little Open from Vault commandbutton is not on the VBA launched, Inventor style, file dialog. Is there a way to mimic what is launched from the GUI. I basically want to give the users the ability to open assemblies from the Vault that are not on their workspace.

 

Here is the code I found:

Public Sub TestFileDialog()

    'Inventor style open dialog
    
    
    'Create a new FileDialog object.
    Dim oFileDlg As FileDialog
    Call ThisApplication.CreateFileDialog(oFileDlg)
    
    ' Define the filter to select part and assembly files or any file.
    oFileDlg.Filter = "Inventor Files(*.iam;*.ipt)|*.iam;*.ipt|All Files (*.*)|*.*"
    
    
    ' Define the part and assembly files filter to be the default filter.
    oFileDlg.FilterIndex = 1
    
    ' Set the title for the dialog.
    oFileDlg.DialogTitle = "Open File Test"
    
    ' Set the initial directory that will be displayed in the dialog.
    oFileDlg.InitialDirectory = "C:\Temp"
        
    'Set the flag so an error will be raised if the user clicks the Cancel button.
    oFileDlg.CancelError = True

    ' Show the open dialog.  The same procedure is also used for the Save dialog.
    ' The commented code can be used for the Save dialog.
    On Error Resume Next
    oFileDlg.ShowOpen
    'oFileDlg.ShowSave
    
    ' If an error was raised, the user clicked cancel, otherwise display the filename.
    If Err Then
        MsgBox "User cancelled out of Dialog"
    ElseIf oFileDlg.Filename <> "" Then
        MsgBox "File " & oFileDlg.Filename & " was selected."
    End If
End Sub

Is there a property that can be set so the Open from Vault commandbutton appears on the file dialog?

 

Any help with this would be greatly appreciated.

 

Rafael Colon

Abtex Inc.

 

0 Likes
1,273 Views
1 Reply
Reply (1)
Message 2 of 2

rcolon9E4ZX
Advocate
Advocate

Any luck with this? I want to create an Open from Vault file dialog using VBA.

 

 

Rafael Colon

Abtex Inc.

0 Likes