Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Importing Text File Data into Excel where records span several row | Excel Discussion (Misc queries) | |||
importing text file in excel | Excel Discussion (Misc queries) | |||
How do I search a text string in many excel worksheets (files)? | Excel Worksheet Functions | |||
Importing a text file into Excel with too many rows? | Excel Discussion (Misc queries) | |||
Importing Text Files | Excel Discussion (Misc queries) |