Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Why Im I getting an error in code..
Why Im I getting an error in the partial code below??
Im trying to import a tezt file, but when I try to run it it highlights the FName line and says the following messege: "Expected: line# or label or statement or end of statement" FName= F:\trial2.txt For Input As #1 Open FName For Input Access Read As #1 ......................... ......................... ......................... Thanks in advance |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Why Im I getting an error in code..
FName = "F:\trial2.txt"
Would be my first attempt. N.F wrote: Why Im I getting an error in the partial code below?? Im trying to import a tezt file, but when I try to run it it highlights the FName line and says the following messege: "Expected: line# or label or statement or end of statement" FName= F:\trial2.txt For Input As #1 Open FName For Input Access Read As #1 ........................ ........................ ........................ Thanks in advance -- Dave Peterson |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Why Im I getting an error in code..
And then I'd look at Chip Pearson's sample code:
http://cpearson.com/excel/ImpText.aspx N.F wrote: Why Im I getting an error in the partial code below?? Im trying to import a tezt file, but when I try to run it it highlights the FName line and says the following messege: "Expected: line# or label or statement or end of statement" FName= F:\trial2.txt For Input As #1 Open FName For Input Access Read As #1 ........................ ........................ ........................ Thanks in advance -- Dave Peterson |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Why Im I getting an error in code..
Why Im I getting an error in the partial code below??
Im trying to import a tezt file, but when I try to run it it highlights the FName line and says the following messege: "Expected: line# or label or statement or end of statement" FName= F:\trial2.txt For Input As #1 I am not sure what the For Input As #1 part is supposed to be doing... you are just trying to assign the path to the variable, right? FName = "F:\trial2.txt" Note the quote marks. Rick |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Why Im I getting an error in code..
Tried the quotations and still didnt work. Hey Rick I expanded on the code so
that u can look at why the For #1 statement does: I think the #1 statmetnt is referred in the code in the line that states " Line Input #1. See below FName = "F:trial2.txt" For Input As #1 Open FName For Input Access Read As #1 ............. ............ While Not EOF(1) Line Input #1, WholeLine If Right(WholeLine, 1) < sp Then WholeLine = WholeLine & sp End If "Rick Rothstein (MVP - VB)" wrote: Why Im I getting an error in the partial code below?? Im trying to import a tezt file, but when I try to run it it highlights the FName line and says the following messege: "Expected: line# or label or statement or end of statement" FName= F:\trial2.txt For Input As #1 I am not sure what the For Input As #1 part is supposed to be doing... you are just trying to assign the path to the variable, right? FName = "F:\trial2.txt" Note the quote marks. Rick |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Why Im I getting an error in code..
Thanks dave I will look at that website shortly. I tried the quotations and
still didnt work. "Dave Peterson" wrote: And then I'd look at Chip Pearson's sample code: http://cpearson.com/excel/ImpText.aspx N.F wrote: Why Im I getting an error in the partial code below?? Im trying to import a tezt file, but when I try to run it it highlights the FName line and says the following messege: "Expected: line# or label or statement or end of statement" FName= F:\trial2.txt For Input As #1 Open FName For Input Access Read As #1 ........................ ........................ ........................ Thanks in advance -- Dave Peterson |
#7
Posted to microsoft.public.excel.misc
|
|||
|
|||
Why Im I getting an error in code..
Hey dave that is the website that I got my macro from.
So actually im not sure if thats gonna help me out any more But thanks though. Any other ideas?? "Dave Peterson" wrote: And then I'd look at Chip Pearson's sample code: http://cpearson.com/excel/ImpText.aspx N.F wrote: Why Im I getting an error in the partial code below?? Im trying to import a tezt file, but when I try to run it it highlights the FName line and says the following messege: "Expected: line# or label or statement or end of statement" FName= F:\trial2.txt For Input As #1 Open FName For Input Access Read As #1 ........................ ........................ ........................ Thanks in advance -- Dave Peterson |
#8
Posted to microsoft.public.excel.misc
|
|||
|
|||
Why Im I getting an error in code..
Better:
FName = "F:\trial2.txt" Fnum = Freefile() ' gives next available buffer # Open FName For Input As #Fnum Do While Not EOF(Fnum) Line Input #Fnum,WholeLine .... .... Loop Close #Fnum Since you're only reading it, not really necessary to use the Access Read. In a way you're assigning a file to a 'variable' when you do the open. Picture the #1 or #Fnum as assigning a communication path (and more) to that file. The Freefile() function returns the next available number for such operations - they can go from 1 to 255. It's best to use it, especially if you are working with multiple files. "N.F" wrote: Tried the quotations and still didnt work. Hey Rick I expanded on the code so that u can look at why the For #1 statement does: I think the #1 statmetnt is referred in the code in the line that states " Line Input #1. See below FName = "F:trial2.txt" For Input As #1 Open FName For Input Access Read As #1 ............ ........... While Not EOF(1) Line Input #1, WholeLine If Right(WholeLine, 1) < sp Then WholeLine = WholeLine & sp End If "Rick Rothstein (MVP - VB)" wrote: Why Im I getting an error in the partial code below?? Im trying to import a tezt file, but when I try to run it it highlights the FName line and says the following messege: "Expected: line# or label or statement or end of statement" FName= F:\trial2.txt For Input As #1 I am not sure what the For Input As #1 part is supposed to be doing... you are just trying to assign the path to the variable, right? FName = "F:\trial2.txt" Note the quote marks. Rick |
#9
Posted to microsoft.public.excel.misc
|
|||
|
|||
Why Im I getting an error in code..
Thank you JLatham Ill give that a try.
"JLatham" wrote: Better: FName = "F:\trial2.txt" Fnum = Freefile() ' gives next available buffer # Open FName For Input As #Fnum Do While Not EOF(Fnum) Line Input #Fnum,WholeLine ... ... Loop Close #Fnum Since you're only reading it, not really necessary to use the Access Read. In a way you're assigning a file to a 'variable' when you do the open. Picture the #1 or #Fnum as assigning a communication path (and more) to that file. The Freefile() function returns the next available number for such operations - they can go from 1 to 255. It's best to use it, especially if you are working with multiple files. "N.F" wrote: Tried the quotations and still didnt work. Hey Rick I expanded on the code so that u can look at why the For #1 statement does: I think the #1 statmetnt is referred in the code in the line that states " Line Input #1. See below FName = "F:trial2.txt" For Input As #1 Open FName For Input Access Read As #1 ............ ........... While Not EOF(1) Line Input #1, WholeLine If Right(WholeLine, 1) < sp Then WholeLine = WholeLine & sp End If "Rick Rothstein (MVP - VB)" wrote: Why Im I getting an error in the partial code below?? Im trying to import a tezt file, but when I try to run it it highlights the FName line and says the following messege: "Expected: line# or label or statement or end of statement" FName= F:\trial2.txt For Input As #1 I am not sure what the For Input As #1 part is supposed to be doing... you are just trying to assign the path to the variable, right? FName = "F:\trial2.txt" Note the quote marks. Rick |
#10
Posted to microsoft.public.excel.misc
|
|||
|
|||
Why Im I getting an error in code..
N.F.
Highjacking this to add to yesterday's post on Row Colors. The code I posted works on one cell at a time only. Try this amended code to allow a larger range to be selected and copied. Sub copy_no_change() Dim rng1 As Range Dim rng2 As Range Set rng1 = Selection Set rng2 = Application.InputBox(Prompt:= _ "Select Any Cell to paste to", Type:=8) rng2.Resize(rng1.Rows.Count, rng1.Columns.Count).Value _ = rng1.Value rng1.ClearContents End Sub Gord On Tue, 7 Aug 2007 15:24:01 -0700, N.F wrote: Hey dave that is the website that I got my macro from. So actually im not sure if thats gonna help me out any more But thanks though. Any other ideas?? "Dave Peterson" wrote: And then I'd look at Chip Pearson's sample code: http://cpearson.com/excel/ImpText.aspx N.F wrote: Why Im I getting an error in the partial code below?? Im trying to import a tezt file, but when I try to run it it highlights the FName line and says the following messege: "Expected: line# or label or statement or end of statement" FName= F:\trial2.txt For Input As #1 Open FName For Input Access Read As #1 ........................ ........................ ........................ Thanks in advance -- Dave Peterson |
#11
Posted to microsoft.public.excel.misc
|
|||
|
|||
Why Im I getting an error in code..
You're welcome - just the final touch to those that started down the path to
assist you before me. "N.F" wrote: Thank you JLatham Ill give that a try. "JLatham" wrote: Better: FName = "F:\trial2.txt" Fnum = Freefile() ' gives next available buffer # Open FName For Input As #Fnum Do While Not EOF(Fnum) Line Input #Fnum,WholeLine ... ... Loop Close #Fnum Since you're only reading it, not really necessary to use the Access Read. In a way you're assigning a file to a 'variable' when you do the open. Picture the #1 or #Fnum as assigning a communication path (and more) to that file. The Freefile() function returns the next available number for such operations - they can go from 1 to 255. It's best to use it, especially if you are working with multiple files. "N.F" wrote: Tried the quotations and still didnt work. Hey Rick I expanded on the code so that u can look at why the For #1 statement does: I think the #1 statmetnt is referred in the code in the line that states " Line Input #1. See below FName = "F:trial2.txt" For Input As #1 Open FName For Input Access Read As #1 ............ ........... While Not EOF(1) Line Input #1, WholeLine If Right(WholeLine, 1) < sp Then WholeLine = WholeLine & sp End If "Rick Rothstein (MVP - VB)" wrote: Why Im I getting an error in the partial code below?? Im trying to import a tezt file, but when I try to run it it highlights the FName line and says the following messege: "Expected: line# or label or statement or end of statement" FName= F:\trial2.txt For Input As #1 I am not sure what the For Input As #1 part is supposed to be doing... you are just trying to assign the path to the variable, right? FName = "F:\trial2.txt" Note the quote marks. Rick |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Code error | Excel Discussion (Misc queries) | |||
Error in Code | Excel Discussion (Misc queries) | |||
error in this code | Excel Worksheet Functions | |||
Code Error | Excel Discussion (Misc queries) | |||
Code error ?? | Excel Discussion (Misc queries) |