browse?!
i know this is probably not the right forum, but still, i try it.
i need a button to browse my computer for one file, the selected file should be inserted (with the path) into a textfield, where i go on with working with it. it's in a ms access-application.
i know there must be a way to do it... BTW: Win NT-platform. thanks for any help!
Mark Hensler posted this at 04:55 — 1st December 2000.
He has: 4,048 posts
Joined: Aug 2000
you mean like in visual basic?
I don't know that off the top of my head, but I think I can get it for you pretty easy...
or in html?
other language?
Mark Hensler
If there is no answer on Google, then there is no question.
merlin posted this at 07:14 — 1st December 2000.
They have: 410 posts
Joined: Oct 1999
yes, in visual basic. we have some really great cracks in vb in here, but well, they knew it can be done but didn't know how...
thank you for your help, i really appreciate that!
Mark Hensler posted this at 03:26 — 2nd December 2000.
He has: 4,048 posts
Joined: Aug 2000
well, it says in this here book (some VB book off my bedroom floor )...
[I'm assuming your using Microsoft Visual Basic 6 (the program) to write this.]
On the left, in your 'toolbox' you'll need to find the 'Common Dialog Box' control. If it's not there, just right click the 'toolbox' and select 'components...'. Scroll down in the textbox untill you find 'Microsoft Common Dialog Control 6.0'. Check the box to the left and click 'OK'. Now the control should be in your 'toolbox'.
Moving on... Place the Common Dialog Box control anywhere on your form. Now name your control (let's say cdbDialog). Now wherever you need to use that 'give me a file' thingy, simply use:
'the following code is right out of the book
cdbDialog.DialogTitle = "File Open"
cdbDialog.Filter = "*.txt" 'show only text files
cdbDialog.FileName = "*.txt" 'default filename
cdbDialog.ShowOpen 'trigger the dialog box
Need more help, feel free to ask. Also you might want to check out these search results (for 'common dialog box') at MSDN.
Good Luck,
Mark Hensler
If there is no answer on Google, then there is no question.
merlin posted this at 16:44 — 4th December 2000.
They have: 410 posts
Joined: Oct 1999
yes, that worked!
well, to be honest, it was quite a lot of work too: i had to install ms access 2000, developer version, and then it worked...
thank you max!
ali
merlin posted this at 10:35 — 6th December 2000.
They have: 410 posts
Joined: Oct 1999
as i mentioned, the dialog box worked. but now: how do i get the path of the selected file?
the file name i get:
object.filetitle
but how can i get that path? ???
in the docs there is nothing mentioned, but i'm sure it's somehow possible... thank you!
Mark Hensler posted this at 07:54 — 7th December 2000.
He has: 4,048 posts
Joined: Aug 2000
hmm... I overlooked that, sorry.
All I can find in these books (2 VB books) is this:
Private Sub cmdShowOpen_Click()
' Show the open dialog bos
CommonDialog1.ShowOpen
' Show the filename selected
txtReturn.Text = "FileName = " & CommonDialog1.FileName
End Sub
You said your doing something with Access, are you using VBA then? I'm not to sure if there is a difference. I've never written anything for Access. So I'm just speaking from the standpoint of a Visual Basic 6 programmer.
Here is some more stuff...
I took this from this page, which I found from these search results for "common dialog box open" at msdn.microsoft.com
Public Function GetFileToOpen()
Dim fileflags As FileOpenConstants
Dim filefilter As String
'Set the text in the dialog title bar
CommonDialog1.DialogTitle = "Open"
'Set the default file name and filter
CommonDialog1.InitDir = "\"
CommonDialog1.FileName = ""
filefilter = "Visual Basic Files (*.vb)|*.vb|All Files (*.*)|*.*"
CommonDialog1.Filter = filefilter
CommonDialog1.FilterIndex = 0
'Verify that the file exists
fileflags = cdlOFNFileMustExist
CommonDialog1.Flags = fileflags
'Show the Open common dialog box
CommonDialog1.ShowOpen
'Return the path and file name selected or
'Return an empty string if the user cancels the dialog
GetFileToOpen = CommonDialog1.FileName
End Function
more helpfull links from MSDN:
CommonDialog Control (Open, Save As Dialogs)
that's all I can find now... need to get some sleep
Good Luuck,
Mark Hensler
If there is no answer on Google, then there is no question.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.