View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Excel - Importing Text Files

Are you using a macro to import the text files?

If yes, maybe change some of your code so that it doesn't point at the exact
name of the files (drop the hardcoded path from your code).

Dim myBaseName1 as string
Dim myBaseName2 as string
dim myPath as string
dim testStr as string
dim ErrorFound as Boolean

mypath = thisworkbook.path
mybasename1 = "somefile1.txt"
mybasename2 = "somefile2.txt"

teststr = ""
on error resume next
teststr = dir(mypath & "\" & mybasename1
on error goto 0

errorfound = false
if teststr = "" then
errorfound = true
msgbox mybasename1 & " wasn't found"
end if

teststr = ""
on error resume next
teststr = dir(mypath & "\" & mybasename2
on error goto 0

if teststr = "" then
errorfound = true
msgbox mybasename2 & " wasn't found"
end if

if errorfound then
exit sub
end if

'now use mypath & "\" & mybasename1
' and mypath & "\" & mybasename2
'to open your text files


(Untested, uncompiled--watch for typos)

PW11111 wrote:

Hi,

I have designed a spread sheet - it automatically imports two .txt files.

Now I have the generic sheet I need to duplicate it for every building my
company has.

I've made a new folder for each building. Each folder has a copy of the
spreadsheet and its specific .txt files (which are always called the same).

However - the sheet always references the original .txt files I used when I
designed the sheet.

I need someway to tell the spreadsheet to import the .txt files located in
the same folder.

Any help would be great.

Cheers,
Phil


--

Dave Peterson