Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 65
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,202
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 65
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 65
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 65
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 65
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default 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
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
Code error M&M[_2_] Excel Discussion (Misc queries) 4 July 13th 07 12:20 AM
Error in Code N.F[_2_] Excel Discussion (Misc queries) 9 June 27th 07 06:48 PM
error in this code [email protected] Excel Worksheet Functions 2 December 5th 06 05:21 AM
Code Error Tom Excel Discussion (Misc queries) 0 February 21st 06 03:01 PM
Code error ?? Anthony Excel Discussion (Misc queries) 2 February 9th 05 10:31 PM


All times are GMT +1. The time now is 02:02 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"