• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

how to choose a folder in vba

Adahm

Guest
Bye to all,

I’m looking for the way to select a windows folder, so you can use it as a destination in saving some files.
I found this code:
Code:
dim shellapp as object

'create a file browser window in the default folder
shellapp set = createobject("shell.application"). _
browseforfolder(0, "choose the folder", 0, openat)
...
but it opens me a somewhat obsolete window that does not allow me an easy navigation.

There is also this other way I use in access to do the same thing:
Code:
    ...
    set fd = application.filedialog(msofiledialogfolderpicker)
    ...
but in inventor does not work.

looking on autodesk chats, I think I understand that in inventor you can open or save files using windows selection windows, but not to select folders.
Does anyone know anything more?
 
if someone should serve, I discovered that inventor does not recognize "msofiledialogfolderpicker" that is to be replaced with a very simple "4".
then the simplified code could be as follows:
Code:
sub mostracartellaselezionata()
    dim selectedfolder

    with application.filedialog(4)
        .show
        selectedfolder = .selecteditems(1)
    end with

    ' mostra l'indirizzo della cartella selezionata
    msgbox (selectedfolder)
end sub
 
hi, I don't know if that's what you need but I use this block to choose the folder from time to time during the current operation (vb.net):

dim dialog = new folderbrowserdialog with {
.selectedpath = percorso di default,
.shownewfolderbutton = true,
.description = "scegli la cartella dove salvare i file."
}
if dialogresult.ok = dialog.showdialog() then
ofilepath = dialog.selectedpath & "\"
else
messagebox.show("procedura annullata.", "info")
return
end if
 
hi, I don't know if that's what you need but I use this block to choose the folder from time to time during the current operation (vb.net):

dim dialog = new folderbrowserdialog with {
.selectedpath = percorso di default,
.shownewfolderbutton = true,
.description = "scegli la cartella dove salvare i file."
}
if dialogresult.ok = dialog.showdialog() then
ofilepath = dialog.selectedpath & "\"
else
messagebox.show("procedura annullata.", "info")
return
end if
Thank you.
but this is in vb.net.
I use vba and the code is slightly different.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top