Retrieve another file's path and record in txt box

B

Benthos

Hello all,

I have a desire to record another files path and record it in a text box in
a form in Excel. I would like a "file open" type box to appear after a
lookup button is pressed and for me to be able to search my computers file
system, find a file, and then record it's filename and path in a text box.

The goal it go get it to print out in a work document and be a link to open
the document. The type of file I will be looking for is an MS project file,
but I would assume it makes no difference.

If any of you know how to do this that would be great.
Thanks!
Ben
 
B

Benthos

Thanks for that, but I have a follow up question. When I try to load the
Common Dialog control to the toolbox and use it, I get a class not registered
error. I have the commdlg.dll file in the system folder.
Any Ideas?
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?QmVudGhvcw==?=,
I have a desire to record another files path and record it in a text box in
a form in Excel. I would like a "file open" type box to appear after a
lookup button is pressed and for me to be able to search my computers file
system, find a file, and then record it's filename and path in a text box.

The goal it go get it to print out in a work document and be a link to open
the document. The type of file I will be looking for is an MS project file,
but I would assume it makes no difference.
The problem with Jezebel's suggestion is that this control is part of VB6 (not
Office) and it's therefore not guaranteed that it will be present on all
machines. If you're working with Office 2002 or 2003, then it might be better
to use the built-in Office FileDialog object.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
B

Benthos

Thank you for this information. It has been very helpful so far.
I am using the dialogs but I am not sure how to aquire the file name and
path of the selected file with out opening it. I have used xlDialogFindFile
and xlDialogOpen, but I don't know where to go once I navigate and select the
file I desire.
 
B

Benthos

I got it now...here is the code I used...
Private Sub cmdFindLoc_Click()

Dim rngLoc As Range
Set rngLoc = Sheets("TestInfo").Range("SMSProjectLoc").Offset(0, 1)
rngLoc = Application.GetOpenFileName()
txtMSProjectLoc.Value = Range("TestInfo!SMSProjectLoc").Offset(0, 1).Value
Set rngLoc = Nothing
End Sub
 
Top