Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code can't locate filename
The following code fails to locate the filename path specified returning "file not found" error. There is surely a file named "tester'" in C:\ Mydocuments folder. What gives? TIA Sub Import_TextFiles1() Dim RwIndx As Integer Dim ColIndx As Integer Dim WholeLine As String Dim Fname As String Application.ScreenUpdating = False ColIndx = ActiveCell.Column RwIndx = ActiveCell.Row Fname = "C:\My Documents\tester.doc" Open Fname For Input Access Read As #1 While Not EOF(1) Line Input #1, WholeLine Cells(RwIndx, ColIndx).Value = WholeLine RwIndx = RwIndx + 1 Wend Close #1 Application.ScreenUpdating = True -- davidm ------------------------------------------------------------------------ davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645 View this thread: http://www.excelforum.com/showthread...hreadid=387955 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code can't locate filename
"davidm" wrote in
message ... The following code fails to locate the filename path specified returning "file not found" error. There is surely a file named "tester'" in C:\ Mydocuments folder. What gives? TIA Hi David, If the error message tells you there's no such file then I would guess there is no such file. Add the following lines of code to verify the existence of your file prior to opening it: If Len(Dir$(Fname)) = 0 Then MsgBox Fname & " could not be located.", vbCritical, "Error!" Exit Sub End If If you see the error message then the file is not there. -- Rob Bovey, Excel MVP Application Professionals http://www.appspro.com/ * Take your Excel development skills to the next level. * Professional Excel Development http://www.appspro.com/Books/Books.htm "davidm" wrote in message ... The following code fails to locate the filename path specified returning "file not found" error. There is surely a file named "tester'" in C:\ Mydocuments folder. What gives? TIA Sub Import_TextFiles1() Dim RwIndx As Integer Dim ColIndx As Integer Dim WholeLine As String Dim Fname As String Application.ScreenUpdating = False ColIndx = ActiveCell.Column RwIndx = ActiveCell.Row Fname = "C:\My Documents\tester.doc" Open Fname For Input Access Read As #1 While Not EOF(1) Line Input #1, WholeLine Cells(RwIndx, ColIndx).Value = WholeLine RwIndx = RwIndx + 1 Wend Close #1 Application.ScreenUpdating = True -- davidm ------------------------------------------------------------------------ davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645 View this thread: http://www.excelforum.com/showthread...hreadid=387955 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VB Code Help - locate and sum | Excel Discussion (Misc queries) | |||
set filename to <filename-date on open | Excel Worksheet Functions | |||
VBA code to locate cell address of AutoFilter dropdown box | Excel Discussion (Misc queries) | |||
VBA code using Find to locate text and display the Cell Range. | Excel Programming | |||
Saving filename same as import filename | Excel Programming |