|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Read from text file
How do I read values from a text file into an Array in my word Macro?
|
|
#2
|
||||
|
||||
|
read your text file in as a string, and use the following implementation
Code:
dim strRead as string dim strArray() as string 'open and read your text into strRead 'then do the following to split the string on spaces strArray = split(strRead," ") for example, if strRead had the string "Every Good Boy Does Fine", then strArray(2) would hold "Boy" after the assignment.
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#3
|
||||
|
||||
|
Quote:
Thanks, but how do I actually open the file and read it into strRead? |
|
#4
|
||||
|
||||
|
OHHHH.... sorry
![]() Open "C:\YourInputFile.txt" for input as #1 like so... Code:
Dim strTemp As String Open "Yourfile.txt" For Input As #1 Do Until EOF(1) Line Input #1, strTemp Loop |
|
#5
|
||||
|
||||
|
Thanks!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Read from text file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|