Results 1 to 4 of 4

Thread: How to show a browse box

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 1999
    Location
    Sydney
    Posts
    13

    Post

    A simple one but could anyone tell me the code for displaying a browse box? I then want to display the file path of what is selected in the browse box to a text box. Do I have to create my own browse box (how?)or does VBA have a pre-defined one? I'm using the VB Editor in excel 97.

    Thanks

    Mark

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    You could use a CommonDialog Control (You need to add it to your project the same way you add TextBox or Label - in canse you were wondering).
    Code:
    'It will show the browser box
    CommonDialog1.ShowOpen
    'It will print the text to a TextBox
    Text1.Text = CommonDialog1.FileName
    I believe it should be something like this but if it doesn't work then just play around with CommonDialog Control and you will find the solution for your problem.

    Regards Marek

    ------------------
    Visual Basic Programmer (at least I want to be one)
    ------------------
    PolComSoft
    You will hear a lot about it.



    [This message has been edited by QWERTY (edited 12-06-1999).]

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 1999
    Location
    Sydney
    Posts
    13

    Post

    Thanks Marek,

    but how do I activate this commonDialog property? I can't find any help on it in the VBE editor (Excel 97). Do I need to call an API for it or can I just declare it as an object that already exists in the VBA library?

    thanks

    Mark

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    galpinm, on the VBA toolbox you have a button called More Controls. When you click on it you will be given a dropdown list with all available controls. Select Microsoft Common Dialog Control. Then draw a it in your excel sheet (don't worry about this control beeing invisible). Then, for testing purposes, drop a Textbox and a Command Button onto your worksheet. Double click on the button,w hich will open a code window. Copy this code:
    Code:
    Private Sub CommandButton1_Click()
        With CommonDialog1
            .ShowOpen
            TextBox1.Text = .FileName
        End With
    End Sub
    Press F5, it will ask you to give a name for your macro. Then switch to your worksheet and press the button. It will open a common dialog to select a file and show the filename in the textbox.

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

    Serge

    Software Developer
    Serge_Dymkov@vertexinc.com
    Access8484@aol.com
    ICQ#: 51055819


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width