Commondialog use

Commondialog use

Anonymous
Not applicable
310 Views
4 Replies
Message 1 of 5

Commondialog use

Anonymous
Not applicable
Okay, I thought this was going to be easy but - wrong answer! All I want to do is to create a button to allow the user to browse to find the file they are looking for. (an excel spred sheet to gather information from to create a drawing, another thing I think will be easy, we'll see) so I made this button that uses The Commondialog to show the system open dialog box. Now how do I pass this information back to my form?? I thought it would be as simple as TxtBoxFile.Text = Commondialog1.Filename - Wrong answer again! The help files don't give me diddly and the object browser says thaty the Filename member " Returns/sets the path and filename of a selected file." Sounds like what I want, but that's as far as it goes. Again all I'm trying to do is push a button, show the open dialog box, and then after the user has selected a file and pressed the open button, return to the form and have a text box contain the path and filename they just selected. It can't be that difficult. Is it??
Thanks.
Dave. K
0 Likes
311 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
WOW!! That was fast. I posted this and grabbed another book and found the answeer on the first page I check.
COOL. But I'll be back
sorry to bother y'all.
Dave. K
0 Likes
Message 3 of 5

Anonymous
Not applicable
I remember having trouble with that a long time ago and was trying to
remember the solution, it's been long time since used the cmndlg.
...was it
set cdl = New CDLclassname
filename = cdl.showOpen ????

"KingCAD" wrote in message
news:f17a2b1.0@WebX.maYIadrTaRb...
> WOW!! That was fast. I posted this and grabbed another book and found the
answeer on the first page I check.
> COOL. But I'll be back
> sorry to bother y'all.
> Dave. K
>
0 Likes
Message 4 of 5

Anonymous
Not applicable
Duh?! Showing the open dialog was easy "Commondialog1.show" the problem was getting the name of the file to open from the open dialog, My solution was also easy. It seems you can't simply set a textbox.text to be commondialog1.filename, you havce to first set a variable to be commondialog1.filename(or filetitle) then set the textbox.text to be that variable. like -
With CommonDialog1
.Filter = "Spread Sheets (*.xls)|*.xls"
.ShowOpen
StrFileName = .FileTitle
End With
TxtBoxFile.Text = StrFileName

This gives me just Excel spread sheets, and asigns selected file's path and file name to the textbox.

Duh, pretty simple huh?!
Dave. K
0 Likes
Message 5 of 5

Anonymous
Not applicable
Cool man. Everythings simple once you know how to
do it, but nothing is simple if you don't know how!  That's the great thing
about this kind of forum where so many are willing and able to help
others.

Glad you solved that hurdle, now on to the next
eh?!?

From some notes I found I wondered if

 StrFileName = CommonDialog1.ShowOpen

size=2>would return the name?

I'll have to see if I have a project that used
commondialog to try, or start a new one, but there are other priorities at the
moment.

Curious too what class you were using, do you know
which library you referenced to use it? or was it one of the many api classes
floating around that substitute for the mscommctl or whatever that ocx
was...


🙂

Mark


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Duh?!
Showing the open dialog was easy "Commondialog1.show" the problem was getting
the name of the file to open from the open dialog, My solution was also easy.
It seems you can't simply set a textbox.text to be commondialog1.filename, you
havce to first set a variable to be commondialog1.filename(or filetitle) then
set the textbox.text to be that variable. like -
With CommonDialog1

    .Filter = "Spread Sheets (*.xls)|*.xls"

    .ShowOpen
    StrFileName
= .FileTitle
End With
TxtBoxFile.Text = StrFileName

This gives me just Excel spread sheets, and asigns selected file's path and
file name to the textbox.

Duh, pretty simple huh?!
Dave. K

0 Likes