View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Using a file name to get the path where the file resides

Try this:


Sub gsnu()
Dim s0 As String
Dim s1 As String
Dim s2 As String
Dim s3 As String
Dim s4 As String

s0 = "cd\"
s1 = "findit.bat"
s2 = "dir /s "
s3 = Range("A1").Value
s4 = "pause"

Open s1 For Output As #1
Print #1, s0
Print #1, s2 & s3
Print #1, s4
Close #1

x = Shell("cmd.exe /c findit.bat", 1)

End Sub

This routine uses the contents of cell A1 to create a .bat file. The
routine then executes the .bat file. The .bat file uses the dir command to
do the searching.
--
Gary''s Student


"QuietMan" wrote:

Gary,

thsi opens up a dialog box where the person would have to select the file

I want the code to search for the path based on the file name inputed in a
cell in the worksheet

--
Helping Is always a good thing


"Gary''s Student" wrote:

See:

http://groups.google.com/group/micro...718b529f0a6e60


--
Gary's Student


"QuietMan" wrote:

I printing reports from 4 different files who names change each month
depending on the month and version

I would like to enter the file name in a cell in the worksheet. Then have
the VBA code search and return the path where the file exist

--
Helping Is always a good thing