E
ExcelMonkey
I am trying to load a text file into an array using the following code below.
I have two questions:
1) Why can I not put variable declarations after the Fname$ and Raw$? I get
errors when I try to use String and Variant. Doe the $ denote a variable
type?
2) The code is failing on Txt$ = Split(Raw$, vbCrLf). Its failing because
the text string has multiple line spacing in it (See excerpt of text below).
It there a way to get around this? I am assuming I need a variable parameter
instead of vbCrLf.
Sub GetTextFile()
Dim Fname$
Dim ff As Integer
Dim Raw$
ff = FreeFile
Fname$ = "C:\Documents and Settings\kaczanor\Desktop\Sample.txt"
Open Fname$ For Binary As #ff
Raw$ = String$(LOF(ff), 32)
Get #ff, 1, Raw$
Close #ff
Txt$ = Split(Raw$, vbCrLf)
End Sub
'**********************************************
'Text String Excerpt:
Summary
Parties
Grounds
Decision on costs
Operative part
Keywords
Freedom of movement for persons - Freedom of establishment - Company formed
in accordance with the law of a Member State in which it has its registered
office but in which it conducts no business - Establishment of a branch in
another Member State - Registration refused - Not permissible - Member States
free to adopt measures to combat fraud
(EC Treaty, Arts 52 and 58)
Summary
'*********************************************************
Thanks
EM
I have two questions:
1) Why can I not put variable declarations after the Fname$ and Raw$? I get
errors when I try to use String and Variant. Doe the $ denote a variable
type?
2) The code is failing on Txt$ = Split(Raw$, vbCrLf). Its failing because
the text string has multiple line spacing in it (See excerpt of text below).
It there a way to get around this? I am assuming I need a variable parameter
instead of vbCrLf.
Sub GetTextFile()
Dim Fname$
Dim ff As Integer
Dim Raw$
ff = FreeFile
Fname$ = "C:\Documents and Settings\kaczanor\Desktop\Sample.txt"
Open Fname$ For Binary As #ff
Raw$ = String$(LOF(ff), 32)
Get #ff, 1, Raw$
Close #ff
Txt$ = Split(Raw$, vbCrLf)
End Sub
'**********************************************
'Text String Excerpt:
Summary
Parties
Grounds
Decision on costs
Operative part
Keywords
Freedom of movement for persons - Freedom of establishment - Company formed
in accordance with the law of a Member State in which it has its registered
office but in which it conducts no business - Establishment of a branch in
another Member State - Registration refused - Not permissible - Member States
free to adopt measures to combat fraud
(EC Treaty, Arts 52 and 58)
Summary
'*********************************************************
Thanks
EM