PDA

Click to See Complete Forum and Search --> : How to show a browse box


galpinm
Dec 5th, 1999, 09:05 AM
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

QWERTY
Dec 5th, 1999, 11:27 AM
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).

'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).]

galpinm
Dec 5th, 1999, 12:42 PM
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

Serge
Dec 5th, 1999, 06:31 PM
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:

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 (http://www.icq.com/51055819)