Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

code for opening folder

3 REPLIES 3
Reply
Message 1 of 4
akosi
508 Views, 3 Replies

code for opening folder

hi

i need some help in opening a specific folder and user can select the file using vba.

 

i need to include it in the rest of my macro.

 

please help Smiley Frustrated

3 REPLIES 3
Message 2 of 4
Curtis_Waguespack
in reply to: akosi

Hi  akosi,

 

Here is an example:

 

 

Public Sub TestFileDialog()
    ' 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

 

This example came from here:

 

 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 3 of 4
akosi
in reply to: Curtis_Waguespack

thanks a lot Smiley Happy

Message 4 of 4
akosi
in reply to: Curtis_Waguespack

oFileDlg.InitialDirectory = "C:\Temp" 

 

this code doesnt work for me...

 

it doesnt point to whatever i put as the initial directory.

 

help help help!!!Smiley Frustrated

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report