Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
biff biff is offline
external usenet poster
 
Posts: 6
Default importing a .csv so data on new lines?

I have a csv file. The data is separated by commas and each record is on a
new line. Is there any way to import the data into Word so that the data
that is separated by commas in the csv appears on a new line within Word
while each record is separated by a blank line?
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Steve Yandl[_3_] Steve Yandl[_3_] is offline
external usenet poster
 
Posts: 11
Default importing a .csv so data on new lines?

Here is one option.

'--------------------------------------------------------------


Sub SpecCSVimport()

Const ForReading = 1

Dim strPath As String
Dim strLine As String
Dim i As Integer
Dim arrFileLines() As String
Dim arrOneLine() As String
Dim fso

strPath = "C:\Test\My CSV.csv"

Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(strPath) Then
Exit Sub
End If

If Not LCase(fso.GetExtensionName(strPath)) = "csv" Then
Exit Sub
End If

Set objFile = fso.OpenTextFile(strPath, ForReading)
i = 0
Do Until objFile.AtEndOfStream
ReDim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop

objFile.Close

For n = 0 To UBound(arrFileLines)
strLine = ""
arrOneLine = Split(arrFileLines(n), ",")
For x = 0 To UBound(arrOneLine)
strLine = strLine & arrOneLine(x) & vbCrLf
Next x
Selection.TypeText Text:=strLine
Selection.TypeParagraph
Next n

Set fso = Nothing

End Sub

'--------------------------------------------------------------

Steve Yandl



"biff" wrote in message
...
I have a csv file. The data is separated by commas and each record is on
a
new line. Is there any way to import the data into Word so that the data
that is separated by commas in the csv appears on a new line within Word
while each record is separated by a blank line?


  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Yves Dhondt Yves Dhondt is offline
external usenet poster
 
Posts: 767
Default importing a .csv so data on new lines?

Well you could just copy paste your data into Word and then do two find
replace operations:

1)Replace "^p" by "^p^p"
2)Replace "," by "^p"

If you don't want paragraphs but rather soft enters within a record, you
could use "^l" for the replacement option in the second part.

Yves

"biff" wrote in message
...
I have a csv file. The data is separated by commas and each record is on a
new line. Is there any way to import the data into Word so that the data
that is separated by commas in the csv appears on a new line within Word
while each record is separated by a blank line?


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Yves Dhondt Yves Dhondt is offline
external usenet poster
 
Posts: 767
Default importing a .csv so data on new lines?


Well you could just copy paste your data into Word and then do two find
replace operations:

1)Replace "^p" by "^p^p"
2)Replace "," by "^p"

If you don't want paragraphs but rather soft enters within a record, you
could use "^l" for the replacement option in the second part.

Yves

"biff" wrote in message
...
I have a csv file. The data is separated by commas and each record is on a
new line. Is there any way to import the data into Word so that the data
that is separated by commas in the csv appears on a new line within Word
while each record is separated by a blank line?


  #5   Report Post  
Posted to microsoft.public.word.docmanagement
biff biff is offline
external usenet poster
 
Posts: 6
Default importing a .csv so data on new lines?

Thank you both for the helpful suggestions.

"Yves Dhondt" wrote:

Well you could just copy paste your data into Word and then do two find
replace operations:

1)Replace "^p" by "^p^p"
2)Replace "," by "^p"

If you don't want paragraphs but rather soft enters within a record, you
could use "^l" for the replacement option in the second part.

Yves

"biff" wrote in message
...
I have a csv file. The data is separated by commas and each record is on a
new line. Is there any way to import the data into Word so that the data
that is separated by commas in the csv appears on a new line within Word
while each record is separated by a blank line?


.



  #6   Report Post  
Posted to microsoft.public.word.docmanagement
biff biff is offline
external usenet poster
 
Posts: 6
Default importing a .csv so data on new lines?

Thank you both for the helpful suggestions.

"Yves Dhondt" wrote:

Well you could just copy paste your data into Word and then do two find
replace operations:

1)Replace "^p" by "^p^p"
2)Replace "," by "^p"

If you don't want paragraphs but rather soft enters within a record, you
could use "^l" for the replacement option in the second part.

Yves

"biff" wrote in message
...
I have a csv file. The data is separated by commas and each record is on a
new line. Is there any way to import the data into Word so that the data
that is separated by commas in the csv appears on a new line within Word
while each record is separated by a blank line?


.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need some help importing data Yookaroo Mailmerge 3 July 7th 09 10:35 PM
importing data from excel spaceage New Users 1 November 13th 07 09:51 AM
Importing data for labels miso Microsoft Word Help 2 March 29th 07 08:41 PM
importing data source 2373 Microsoft Word Help 2 July 1st 06 03:20 AM
Importing excel file into Word without the grid lines Bronco Microsoft Word Help 2 March 27th 06 01:35 AM


All times are GMT +1. The time now is 12:07 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"