|
-
Dec 5th, 1999, 10:05 AM
#1
Thread Starter
New Member
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
-
Dec 5th, 1999, 12:27 PM
#2
Fanatic Member
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).]
-
Dec 5th, 1999, 01:42 PM
#3
Thread Starter
New Member
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
-
Dec 5th, 1999, 07:31 PM
#4
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
[email protected]
[email protected]
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|