Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Excel - Importing Text Files

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 195
Default Excel - Importing Text Files

Is there anywhere in the spreadsheet before import that Indentifies the
building you are in ?
Or maybe you could use the computer or user name to create link to the
correct TXT file.
eg:
if building1 or compname1 or user name1 then import textfile1.txt
else
if building2 or compname2 or user name2 then import textfile1.txt
End if

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


  #3   Report Post  
Posted to microsoft.public.excel.misc
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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing Text File Data into Excel where records span several row Razorback76 Excel Discussion (Misc queries) 2 June 25th 06 06:36 AM
importing text file in excel UT Excel Discussion (Misc queries) 0 March 16th 06 10:20 PM
How do I search a text string in many excel worksheets (files)? TC628 Excel Worksheet Functions 0 February 8th 06 12:09 AM
Importing a text file into Excel with too many rows? Nexan Excel Discussion (Misc queries) 2 August 17th 05 01:52 PM
Importing Text Files smith_gw Excel Discussion (Misc queries) 1 May 5th 05 10:42 PM


All times are GMT +1. The time now is 08:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"