|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How should I select a folder, create and select the folder?I have a dialog in which I give users an option to select from a list
box multiple text files to save. They have the option to save individual files or to append the text into one file. What is a good way to allow the user to either 1) Select/return an existing folder/path to save the files in, or 2) Create a new folder for the files and return the path. The individual file names are assigned with code so it is only the folder that has to be chosen. Advice will be appreciated, Stan Hilliard
Show quote
Hide quote
"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote Here is one method, available for systems with IE 4 or greater:> I have a dialog in which I give users an option to select from a list > box multiple text files to save. They have the option to save > individual files or to append the text into one file. > > What is a good way to allow the user to either > > 1) Select/return an existing folder/path to save the files in, or > > 2) Create a new folder for the files and return the path. > > The individual file names are assigned with code so it is only the > folder that has to be chosen. > > Advice will be appreciated, Stan Hilliard Private Sub Form_Load() MsgBox GetFolderName End Sub Private Function GetFolderName() Dim sa, bff Set sa = CreateObject("Shell.Application") If (Not sa Is Nothing) Then Set bff = sa.BrowseForFolder(0, "Where do you want to save the data?", &H40, "") If (Not bff Is Nothing) Then GetFolderName = bff.ParentFolder.ParseName(bff.Title).Path End If End If End Function For more info see MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/objects/shell/browseforfolder.asp Additional (advanced features) example at VBNet: http://www.vbnet.mvps.org/code/browse/browseadv.htm HTH LFS On Mon, 4 Jul 2005 23:08:22 -0500, "Larry Serflaten"
<serfla***@usinternet.com> wrote: Show quoteHide quote > Thanks Larry,>"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote >> I have a dialog in which I give users an option to select from a list >> box multiple text files to save. They have the option to save >> individual files or to append the text into one file. >> >> What is a good way to allow the user to either >> >> 1) Select/return an existing folder/path to save the files in, or >> >> 2) Create a new folder for the files and return the path. >> >> The individual file names are assigned with code so it is only the >> folder that has to be chosen. >> >> Advice will be appreciated, Stan Hilliard > > >Here is one method, available for systems with IE 4 or greater: > >Private Sub Form_Load() > MsgBox GetFolderName >End Sub > >Private Function GetFolderName() >Dim sa, bff > Set sa = CreateObject("Shell.Application") > If (Not sa Is Nothing) Then > Set bff = sa.BrowseForFolder(0, "Where do you want to save the data?", &H40, "") > If (Not bff Is Nothing) Then > GetFolderName = bff.ParentFolder.ParseName(bff.Title).Path > End If > End If >End Function > > >For more info see MSDN: >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/objects/shell/browseforfolder.asp > >Additional (advanced features) example at VBNet: >http://www.vbnet.mvps.org/code/browse/browseadv.htm > >HTH >LFS I was diverted from this project for a couple weeks. That code works good for me. Can you suggest how to make it create a new folder below the one selected? For example, I can use GetFolderName to select C:\XXX\YYY\. What is the best way to let the user add a new folder under that selected folder: C:\XXX\YYY\ZZZ\ ? Sincerely, Stan Hilliard "Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote The browser is a user interface, if anyone were to make a new folder> Can you suggest how to make it create a new folder below the one > selected? using the browser, it would be the user. After the bowser returns, you could then easily make a new folder using the standard VB command MkDir. > I see a New Folder button on the dialog, is it not there for you?> For example, I can use GetFolderName to select C:\XXX\YYY\. > > What is the best way to let the user add a new folder under that > selected folder: C:\XXX\YYY\ZZZ\ ? If the user wanted to create a new folder, they would hit the button and then click twice (or right click for a menu) on the new folder name to rename that folder. LFS On Fri, 15 Jul 2005 22:16:06 -0500, "Larry Serflaten"
<serfla***@usinternet.com> wrote: Show quoteHide quote > No. I have a directory tree that I can select a directory in. Below>"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote > >> Can you suggest how to make it create a new folder below the one >> selected? > >The browser is a user interface, if anyone were to make a new folder >using the browser, it would be the user. > >After the bowser returns, you could then easily make a new folder >using the standard VB command MkDir. > >> >> For example, I can use GetFolderName to select C:\XXX\YYY\. >> >> What is the best way to let the user add a new folder under that >> selected folder: C:\XXX\YYY\ZZZ\ ? > >I see a New Folder button on the dialog, is it not there for you? that I have only two buttons: [OK] and [Cancel] If that instance comes from the browser rather than VB, I have two browsers installed: IE 6 SP1, and Firefox 1.0.4. I assume that IE is the operative browser here. My OS is Win98SE. Could it be that your IE browser version is different from mine? >If the user wanted to create a new folder, they would hit the button I do not have the ability to rename folders in the directory tree.>and then click twice (or right click for a menu) on the new folder name >to rename that folder. They are not selectable. The right click only gives me a "What's This?" menu. Stan Hilliard "Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote It certainly looks that way. > >I see a New Folder button on the dialog, is it not there for you? > > No. I have a directory tree that I can select a directory in. Below > that I have only two buttons: [OK] and [Cancel] > > If that instance comes from the browser rather than VB, I have two > browsers installed: IE 6 SP1, and Firefox 1.0.4. I assume that IE is > the operative browser here. My OS is Win98SE. > > Could it be that your IE browser version is different from mine? Randy Birch has an example of the API route with options to select advanced features. You might try his demo to see what is or is not going to be available on your system: http://www.vbnet.mvps.org/code/browse/browseadv.htm The New Folder Button apparently came with Shell32.dll Ver. 6. I would have thought IE 6 might have upgraded Shell32, as it appears that way from here (W2K ships Ver 5, but I've got Ver 6 installed from somewhere...) Perhaps it won't be available on Win9x?... For more version info, check here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/versions.asp LFS On Sat, 16 Jul 2005 18:44:59 -0500, "Larry Serflaten"
<serfla***@usinternet.com> wrote: Show quoteHide quote > Thanks Larry,>"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote > >> >I see a New Folder button on the dialog, is it not there for you? >> >> No. I have a directory tree that I can select a directory in. Below >> that I have only two buttons: [OK] and [Cancel] >> >> If that instance comes from the browser rather than VB, I have two >> browsers installed: IE 6 SP1, and Firefox 1.0.4. I assume that IE is >> the operative browser here. My OS is Win98SE. >> >> Could it be that your IE browser version is different from mine? > >It certainly looks that way. > >Randy Birch has an example of the API route with options to select >advanced features. You might try his demo to see what is or is not >going to be available on your system: > >http://www.vbnet.mvps.org/code/browse/browseadv.htm > >The New Folder Button apparently came with Shell32.dll Ver. 6. >I would have thought IE 6 might have upgraded Shell32, as it >appears that way from here (W2K ships Ver 5, but I've got Ver 6 >installed from somewhere...) Perhaps it won't be available on >Win9x?... > >For more version info, check here: >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/versions.asp > >LFS I used your original GetFolderName() example and MkDir to make a new sub folder. I have run it on Win98SE and Win XP. The method is sufficient on Win98 but is better on XP with its own new folder button.
Divide a path into a Drivename, Pathname, and Filename?
Definition of an implementation SaveSetting question Return Security Events for Yesterday Emergency: Unicode Characters in a Dataset. Time fired event, error out of stack space How 2 get data from a web form DOS box and ALT_ENTER VB Package Deployment Problem Enumerate Devices |
|||||||||||||||||||||||