View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Browse For a File or Path and enter in a cell

Dim myFileName as string
dim teststr as string

with thisworkbook.worksheets("somesheetname")
myfilename = .range("a1").value & "\" & .range("b1").value
end with

teststr = ""
on error resume next
teststr = dir(myfilename)
on error goto 0

if teststr = "" then
msgbox "That file doesn't exist!
else
'do your stuff
end if

I don't understand the second portion of your question. If you put the name of
the file in a cell and the path in a different cell, then don't you already know
the location of the file and folder?

D. Jones wrote:

I will try to make my question clearer.

I would like to enter a file name in a cell and the path to that file name
in another to use later is a couple of macros.

I would like to use a browse type window (Like in Excel to find a "Save As"
directory location) to select the file and path to that file and have them
entered into a cell in Excel.

"Dave Peterson" wrote:

You could use:

Dim myFileName as variant
myfilename = application.getopenfilename
if myfilename = false then
'use hit cancel
else
activesheet.range("a1").value = myfilename
end if

But I'm not sure what you're really asking.

D. Jones wrote:

Is it posssible in Excel 2003 to Browse to either select a file name or path
that would be entered in a cell for reference or used in a macro?


--

Dave Peterson


--

Dave Peterson