Excel macro help??

C

Chris

Ok, here is what I am trying to do. I have a button which
says "find file". What I want is that when someone clicks
this button, your "open" file box or dialog box pops up
and you can search for the file you want to use. However,
instead of opening the file, it just gives the correct
path of that file. I have a text file that I will be
sending out to people, and they need to save it
somewheres, and then click this "find file" button to
insert that path so another macro can read off of the
location.

I am using Excel 2000, and it is frustrating, this code
works for office xp products, but not with this excel
version:

With Application.FileDialog(msoFileDialogOpen)

.AllowMultiSelect = True
.Show

' Display paths of each file selected
For lngCount = 1 To .SelectedItems.Count
ActiveSheet.Range("I27").Select
Range("I27").Value = .SelectedItems(lngCount)
'MsgBox .SelectedItems(lngCount)
Next lngCount

End With

Any help would be much appreciated!!! Thanks.
 
D

Dan E

Chris

FileName = Application.GetOpenFileName

or just for text files

FileName = Application.GetOpenFilename("Text Files (*.txt),*.txt")

FileName will be a string containing a file path

Dan E
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top