Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Allow User To Browse Path To Save File


My code allows the user to write his results to a file.
However I believe it would be a great advantage to also allow the user to select the path (i.e.: browse explorer style unless there’s a better / easier way) he wishes to save to.

Any clues? I was told that there may exists a tool or built in method to browse?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
User Control - File Browse
Is there a way to make a property of a user control so that in design time, the property (in the VB properties window) will have a little button with an ellipse on it? And when they click it, it will open a file open dialog box where they can choose a file?

It's like how the Picture property works except it won't be for images.

Leting A User Browse For A File?
How do I create a program that lets a user of the program browse for a picturefile on his/her hardrive then display it in a picture box using a command button to display the file?

I have a picture box named "picshowdisplay"

a command named "cmd1"

and a directory list box named "selectfile"

This is what I had code wise.....

Private Sub cmd1_click
If selectfile.showdialog = dialogresult.ok then
' load picture into picturebox
picshowdisplay.image= image.fromfile(selectfile.filename)
end if
endsub

Dialog Box That Allows The User To Browse Folders To Find A File
Hello!
I would like to know which particular VB controls to use so that in a dialog box the user will be able to browse folders in order to find a particular file. Thanks for all the help.

Set The Path For A File To Save.
When I click the BROWSE button to save to a file I would like to have a default Path to the location where I opened the input file.
Is it possible?
How can I do this?

Thanks

Can't Save File Path
I use common dialog control to get the file path of an image file. After I get the path I want to save it in a database. I currently using this code to save the path but seems not working. It saves the path without slash '' character

eg. I want to save c:ghmsyspic1.jpg but it stores 'c:ghmsyspic1.jpg' why it doesn't save the '' character?


VB Code:
cdOpen.Filter = "JPEG |*.jpg"        cdOpen.ShowOpen        sPathPic = cdOpen.FileName        con.Execute "UPDATE patient_info img_path SET img_path = '" & sPathPic & "' WHERE id = " & rec(0) & ";"

Save File To Different Path
I'm using vn.net:

How do i save a file to a different path with the same name.
The following will give me the full path of the file which i don't want. I only want the file name.

Dim FileName As String
FileName = File1.value

File1.PostedFile.SaveAs(("C: emp" & FileName))

How To Save A Path File????
let say i have
1.image control
2.command button control
1.common dialog.

when i click command1 the commondialog will open and ask the user to get a picture file and load it into image control. and then when the user click command2, the picture that has been loaded in the image control will be saved BUT...... only save the PATH of the FILE. how can i do that?

thanks a lot guys!

75 Path/file Access Error , When I Try To Write The File As A Standard User
Hi ,
I am using Windows-xp o.s . i was tried to run the following code in 3 different group membership
1. standard user
2. Restricted user
3. others(Administrators)
i am able to run the code in others(administrator) only but not in standard user & restricted user ie i am getting exception "75 :path/file access error". but i am able to create file as a standard user through windows ie) ( rightclick->new->new text document ) but not through this vb code.why this conflict is happening ? if anyone know the answer kindly reply it ? . thanks in advance.
=================================================
form1
=====
'Creates a file called test1.txt and writes some text into it.
Private Sub Form_Load()

Open "f:Test1.txt" For Output As #1
Write #1, "This is some sample text"
Write #1, "Programmershelp.co.uk"
Close #1

End Sub

====================================================

Save To A Specific File Path?
Hey guys,

I'm not very good with VB6 so please let me know if the following is possible!! I am trying to develop a program in VB6. I don't want the users to have access to the entire C: drive when they save or open the files (using a common dialog). However, I want to give users the freedom to import files from an USB key drive. Is there a way to do this?

Thanks in advance guys!!

Howdi

Determine The Path Of Save File
Hi Gurus,

Do you know how to determine in VBScript or JavaScript the path where a file was save after it was downloaded? When we download a file from a server in Internet, a dialog box will come out and allow us to save to our desired folder. My intention is after I edited the file in Excel, I just click a button in a web page and the file should be uploaded to server without showing the dialog box.

Thank very much in advance.
MsJane

Browse Path
I am using COmmonDialog OCX to allow users to set a file path for my program. It does not look ellegant as I get the user to pick a file first and then manipulate the string to extract only the path. Is there another OCX control which allows users to select the path? Or is there a setting in Commondialog control which allows me to set the path instead of the path and the filename?

Need To Use A Browse Box To Get A Path
I'm trying to figure out how to get a browse box just for a path. I tried using the commondialog but that is just for saving and opening. Does anyone know the omponent that I have to add to get a browse directory box?

How To Get The Word Application File Save As Path When Doc Opened Or Created Thru VB
Dear all

Well I am workinng for following theme.

There is a text box meant for file path and a browse button.
If textbox is empty (by default) then on clicking browse button New Word documents need to be opened. user then writes in that doc and then save that doc to say any path say C:info.doc. When user closes the doc then the path of the doc must be displayed in textbox like c:info.doc

This path will be then stored to database on further action with form items
say clicking Save button

Next Case:

If the record exists for a particular entry in database then on form load the file name will be displayed in the text box.

On clicking browse button now the file path in textbox must be opened and then to be displayed in front of user. If and then the same thing on file close
display the name of the file in the text box again

Sandeep

How To Save File From Server Path To Local Disk(very Very Urgent)
how to save file from server path to local disk(very very urgent) ...?

Browse For Path (common Dialog)
Does anybody know how to display a common dialog to browse for a path? No file.

Im Using A Listview To Browse Files.. How Can I Get The Full Path...?
Im using a listview to browser files. How can i get the full path of where the file is located?

Have VB Save A File Without The User Having To Click Yes To Replace The File
I have a large export that will take 2 or 3 Subs in the command. Both subs sends data into an Excel Template. So, the first sub recalls the template and posts data. The only way I could figure out how to make the second sub post to the same template was to make Excel save the spreadsheet before starting the second sub. But, since the file already exists, it asks the user if they want to replace the spreadsheet. So, as of now, the user has to click the save button 2-3 times to get to the spreadsheet

Does anybody know how to make Excel replace the file without the user seeing it? I would like to have as little user interaction as possible and clicking save to a program they don't see doesn't seem like the way to go

Or does anybody know how to make excel remember to keep using the same spreadsheet through seperate subs?

How To Enable User To Save File As When The File Is Generated By SQL BCP
Database = SQL 2000
Program in VB6

As willl be painfully obvious, I am no programmer; just pitching in trying to help.

What I am trying to do is within a VB6 program...the user selects a menu item to make a copy of data to be saved to a hard drive or cd/dvd burner. The data for the file is stored in a table in a sql 2000 database.

This is the section of the VVB6 program directing the SQL to perform the BCP

sSQL = & _
"declare @sql varchar(8000) " & _
"select @sql = 'bcp [DBName].[dbo].[Tablename] out C:" & lsFileName & ".txt" & " -c -t" & Chr(34) & "/" & Chr(34) & " -T " & _
            "-U" & Chr(34) & "xx" & Chr(34) & " -P" & Chr(34) & "xxxxxx" & Chr(34) & "' exec master..xp_cmdshell @sql"


I would like to know if is possible to replace the C: in the BCP line with a variable that can then be fed to the normal VB File Save As controls, i.e.,
 
    ComDlg.ShowSave
    ComDlg.InitDir = "C:"
    ComDlg.Flags = cdlOFNHideReadOnly + cdlOFNOverwritePrompt + cdlOFNPathMustExist
    ComDlg.FileName = lsFileName

Failing that, is there some other approach that will get me where I am trying to go?

Thanks

I Can Browse For Folder, Now How Can I Browse For File?
I am using this in a module so the user can browse for a folder in my program:

--------------------------------------------------------------------------------

Option Explicit

Public Type BrowseInfo
hwndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type

Public Const BIF_RETURNONLYFSDIRS = 1
Public Const MAX_PATH = 260

Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long


Public Function BrowseForFolder(hwndOwner As Long, sPrompt As String) As String

'declare variables to be used
Dim iNull As Integer
Dim lpIDList As Long
Dim lResult As Long
Dim sPath As String
Dim udtBI As BrowseInfo

'initialise variables
With udtBI
.hwndOwner = hwndOwner
.lpszTitle = lstrcat(sPrompt, "")
.ulFlags = BIF_RETURNONLYFSDIRS
End With

'Call the browse for folder API
lpIDList = SHBrowseForFolder(udtBI)

'get the resulting string path
If lpIDList Then
sPath = String$(MAX_PATH, 0)
lResult = SHGetPathFromIDList(lpIDList, sPath)
Call CoTaskMemFree(lpIDList)
iNull = InStr(sPath, vbNullChar)
If iNull Then sPath = left$(sPath, iNull - 1)
End If

'If cancel was pressed, sPath = ""
BrowseForFolder = sPath

End Function

--------------------------------------------------------------------------------

I will also need the user to select certain files from the hard drive at times, and I don't want to use the common controls dialog, just api. So if somebody could add another function to this module, called "BrowseForFile", which I can control what type of files it can see, I would be very greatful.

Browse And Save.
How can one browse and save a file, and using the same dialog box opened, whereby the save button sends the chosen file to a fixed location. eg C:pics ?

Show Browse For Folder Dialog At A Specified Path Without Using CSIDL Value
Is it possible to show the Browse for Folder dialog using SHBrowseForFolder() to open at a path I specify as opposed to a path from a CSIDL value?

Force User To Save File?
I've a file in specific location (actually it's in word doc.), but I don't want them to mess up with this (b/c it's master copy) instead of forcing them to save to another location (where user desire to copy to). Can anyone give me some hint?

Coding A Browse Button And Returning The Path To A Neighboring Textbox
Hello all

I need your help. As this is probably the most rudimentary question in VBA, but I need to ask it because I am teaching myself and I can't find any information on it.

I need to code a command button in MSWord that will open a directory window to search for image files on your computer and return the path to a textbox in front of it. In essence, How to I make a browse button on a user form?

User Defined Place To Save A File
Yo yo yo

The program that I am writing has the ability to output information in a file. Right now that file is saved to C: emp.txt. I know that there is a way for the user to define where the file should be and its name (you know, click on file then save as).

How can I do that in VB

Save File Names And Dates For User Selection Later
I have a program that does the following: search a folder for any files whose name contains specified text. Once found, search the file for specified text. If the text is found, then store the complete file name and file date to variables, and then continue.

Here is my question. In certain cases there may be several instances of the same file with a slightly different file name in the same folder. I need to save every instance of a file name and file date that is found, and after all have been found, provide the list to the user and have them select the correct one.

What is the best way to do this? I am assuming that it would probably incorporate either an array or collection, and probably a form with a listbox, but maybe there is a better way. I don't use arrays or collections frequently so if it does require them I may need some assistance on proper syntax.

Browse For Folder Then Save Loacation
How do I open the browser so that a user can browse to a folder. Then I would like to take that location a store it in a string. Let me know.

Thanks!

Creating A Browse Save Menu
How do you create a save method that has a browse menu that pops up so the user can designate where they want the file to be saved in?

How Not To Allow User To Browse Above A Certain Folder In DirListBox
Hi,
We have a Dir List Box control in our project.
Double clicking on any folder will refresh the list and list contents of that folder.

Now I want to stop the user frm browsing above a certain level.

For example, the folder structure when the projects loads is D:Experiments1234, where 1234 is the folder of the current experiment the user has opened.
The "Experiments" folder contains more folders, one for each experiment. So the "Experiments" folder contains folders like "1234", "4567", "8900" etc.

I want to stop the user from browsng the "Experiments" folder. The maximum the user can browse should be the current experiment folder which is "1234" in this case.

How can I stop the user from browsing above a certain level?

Limit User Account To Browse Only 1 Web Page
I want to limit the access a Windows account user has to websites. For a given Windows account I want the individual to be only able access one website, for example: *.pbskids.org

ANy IDeas?

How To Check If User Clicks On Save Or Cancel In CommonDialogControl Save Box?
How to check if user clicks on Save or Cancel in CommonDialogControl save box?

Thanks,
Kiran

What Is The Best Way To Save Data As Excel File If I Don't Know User's Excel Version?
do i want to query their version of excel then load
corresponding libraries...

thank you

How Can I Make Files With VB, Or Save Files To A Chosen Directory By Using The Browse
Hi!
I wanna know how to make files in VB. For example a text file.
I also wanna know how to save files to a chosen directory by using the file browser.
This is the code I've used, but it doesn't save the file:

VB Code:
With CommonDialog1     .DialogTitle = "Save"  'sets the dialog title       .InitDir = "C:"  'sets the initial directory       .Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"  'sets the file types      .ShowSave  'show the dialog  End With

Edit: I wanna allow overwriting.

Wan't To Save The Path
I have a text box with a path to hl .exe in. I wan't to save th path the user puts in, so the next time he starts the program, it will be the same path.

Save A Path
Hi
i am trying to save a path to a database but the backslashes () are not saved. eg if a path is "C:Program fileFolder" it saves "C:Program fileFolder" what could be the issue?
i am using mysql and the field is a VARCHAR

Save To The Selected Path
hi
how can i save a work book to a location specified by the user. I mean that whenever the command button(for eg: Save button) is clicked, it shud open up the directories so that one can select his own path to save his file. how can this be achieved in the visual basic code

Thank you

How Do I Create A Path To Save To?
I am trying to build a routine to save the workbook to a pathfilename based on text in my worksheet. I'm more or less good to go, except that I need it to create the path if it doesn't exist. Can anyone point me in the right direction? Here's where I'm starting from:

Range("a5").Select
Selection.Value = stPathName
Range("A6").Select
Selection.Value = stFileName

stPathName = "C:UserData" & stPathName
stSaveAs = stPathName & "" & stFileName

ActiveWorkbook.SaveAs (stSaveAs)

Thanks,
MikeC

Located Db And Save Path..
this is somewhat a newbie question...
i am writting a small app for a client that requires the following..
when the app starts for the first time
it should ask the user to give path to the db (using a dialog box)
when the user finds the database throu dialog boxes
it should store FULL path into a variable i guess..
and then i can use that variable to know where db is
any help would be greatly appreciated

than am gonna write that to a INI file and i can play around with it from there..

thanks

*newbie to this dialog thing, please dont get to technical*

Browse For File
Is there a control or something I can use to allow the user to select a file from their harddrive?

Browse For File
I'm not quite sure what I'm looking for... all I can find on this is info on browseing for Folder's..

What I'm looking for is something that I figured would be basic... since i've seen in just about every program I've ever used... but apprently not...

I want to beable to click a browse button... get an open file dialog and browse to the file. Just like in notepad... when you click File menu and select Open... then in the text box it's made for I want it to path the pathfile an example would be... if I browsed to notepad.exe i'd want it to past... in the text box C:windows
otepad.exe

I think I explained it right... can anyone help me here?... I can't even find info on this other than browseing for folders...which I assume I'm searching for the wrong thing...

I'm new to vb so I'm only assumeing that this is an API thing....

File Browse Help
This is the code i have been using, it has its problems, does anyone want to point out why its a pain to use? thanks


VB Code:
Private Sub Command1_Click()Form1.Label3.ForeColor = 0Form1.Label5 = (Form4.Text1) 'Selected Path Unload MeEnd Sub Private Sub Dir1_Change()   File1.Path = Dir1.PathEnd Sub Private Sub Drive1_Change()On Error GoTo notworkingDir1 = Drive1Exit Subnotworking: MsgBox "The Selected Path has no Data."End Sub Private Sub File1_Click()Text1 = Dir1 & "" & File1End Sub Private Sub Form_Load() End Sub Private Sub Text1_Change() End Sub

How To Browse For A File
Can anyone give me the source code to browse for a file. Is there any function similar to "BrowseForForlder"

Browse For File
Does anybody know how to have a browse for files window pop up when I click a command button?

Browse A Zip File
I was wondering if anyone had written, found, or had any ideas on a way to browse the contents of a zip file through VB without having to extract it all first.

Browse The File..........
hi,
i want to add file(with path) in my textbox.so,i decide to add the browse button...how can i add browse button and file.

Thankyou


with regards
Murugan.

File Browse In IE?
Morning all...

I have done some VB work, but mostly deal with ASP. I need to do a
project (or find one that exists) where the client (Internet Explorer)
can browse their hard drive, and view (only images) as thumbnails. Then
I want to be able to display a check box next to each image so they can
select which files to upload. Right now I have an ASP page that just
allows them to select one file at a time. It is a pain because they are
uploading hundreds a day.

I noticed MS has it on one of their sites. It asks you if you want to
install and run "blah blah" signed on... Etc. I am not sure how to do
this part. I am guessing this is not ActiveX? Can I use VB to do this?

I think I can still use my ASPUpload component to do the uploads, but
will need to do the browsing/selecting in VB... Am I right?

Can anyone shed some light on this and point me in the right direction?

Regards,

Michael C. Gates

Browse For A File
I am trying to allow a user to click a button and browse for a file.  I have found many resources for browsing to a folder, but I want to browse for a specific file.  Here is the browse Folder code that I found, is there anyway to make some minor changes to this to get it to browse to a file or is there a link to browse for a FILE not a folder.  Thanks
CODEPublic Type BrowseInfo
     hwndOwner As Long
     pIDLRoot As Long
     pszDisplayName As Long
     lpszTitle As Long
     ulFlags As Long
     lpfnCallback As Long
     lParam As Long
     iImage As Long
End Type

Public Const BIF_RETURNONLYFSDIRS = 1
Public Const MAX_PATH = 260

Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long

Public Function BrowseForFolder(hwndOwner As Long, sPrompt As String) As String
      
    'declare variables to be used
     Dim iNull As Integer
     Dim lpIDList As Long
     Dim lResult As Long
     Dim sPath As String
     Dim udtBI As BrowseInfo

    'initialise variables
     With udtBI
        .hwndOwner = hwndOwner
        .lpszTitle = lstrcat(sPrompt, "")
        .ulFlags = BIF_RETURNONLYFSDIRS
     End With

    'Call the browse for folder API
     lpIDList = SHBrowseForFolder(udtBI)
      
    'get the resulting string path
     If lpIDList Then
        sPath = String$(MAX_PATH, 0)
        lResult = SHGetPathFromIDList(lpIDList, sPath)
        Call CoTaskMemFree(lpIDList)
        iNull = InStr(sPath, vbNullChar)
        If iNull Then sPath = Left$(sPath, iNull - 1)
     End If

    'If cancel was pressed, sPath = ""
     BrowseForFolder = sPath

End Function

Browse For File In VBA
I'm a novice with VBA and need some help. On a form I'm trying to give the user the ability to browse the file system and select for an ASCII file that will be reformatted and written to a new file. The problem is I don't know how to open a 'select file' dialog and a 'save to' dialog. If someone could even just point me to some sample code or the right control to use, I'd be a happy man.

Thanks

Browse For File
How would I go about creating a Browse for File dialog box? I'm currenting using a Browse for Folder dialog box which works great but I have a need to browse for a file. I would like to be able to browse for a file and have the path and filename enter into a text box.

Best Way For User To Set A Path
I need to provide the user with the ability to set the path where they want to store their files.

Should I be using the commondialog for this -- if so pls give me an idea how to use it for that purpose

Copyright © 2005-08 www.BigResource.com, All rights reserved