Commondialog use

Discussion in 'AutoCAD' started by KingCAD, Jul 23, 2003.

  1. KingCAD

    KingCAD Guest

    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
     
    KingCAD, Jul 23, 2003
    #1
  2. KingCAD

    KingCAD Guest

    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
     
    KingCAD, Jul 23, 2003
    #2
  3. KingCAD

    Mark Propst Guest

    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 ????

    answeer on the first page I check.
     
    Mark Propst, Jul 24, 2003
    #3
  4. KingCAD

    KingCAD Guest

    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
     
    KingCAD, Jul 24, 2003
    #4
  5. KingCAD

    Mark Propst Guest

    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
    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



    "KingCAD" <> wrote in message news:...

    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
     
    Mark Propst, Jul 25, 2003
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.