Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need some help importing data | Mailmerge | |||
importing data from excel | New Users | |||
Importing data for labels | Microsoft Word Help | |||
importing data source | Microsoft Word Help | |||
Importing excel file into Word without the grid lines | Microsoft Word Help |