Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Create table in word from csv
Hi all,
I need to import a csv as a table in a word document with a macro. How can I do this? Can anyone send me a snippet of code? Thanks. Mario |
#2
|
|||
|
|||
Open the file in Word, select all of the text and then from the Table menu
select Convert text to table. In the dialog that appears, check the appropriate separator and you should get a table. -- Please respond to the Newsgroup for the benefit of others who may be interested. Questions sent directly to me will only be answered on a paid consulting basis. Hope this helps, Doug Robbins - Word MVP "_Mario_" wrote in message ... Hi all, I need to import a csv as a table in a word document with a macro. How can I do this? Can anyone send me a snippet of code? Thanks. Mario |
#3
|
|||
|
|||
Word will not import a csv file as a table. You can convert it to a table
once imported. Though how successful this will be will depend on the content of the CSV and how easily Word can determine what are fields and what are records. The following may help you on your way: Documents.Open ("d:\path\filename.csv") Selection.WholeStory Selection.ConvertToTable Separator:=wdSeparateByCommas End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org _Mario_ wrote: Hi all, I need to import a csv as a table in a word document with a macro. How can I do this? Can anyone send me a snippet of code? Thanks. Mario |
#4
|
|||
|
|||
"Graham Mayor" wrote in message ... The following may help you on your way: Documents.Open ("d:\path\filename.csv") Selection.WholeStory Selection.ConvertToTable Separator:=wdSeparateByCommas End Sub That seems to be usefull... but what do U think about creating a Excell app. that load the csv, select all cells and then paste them imto the word doc? Mario |
#5
|
|||
|
|||
No better or worse.
If you have (or added) a paragraph at the top of the .CSV file to hold mergefield names, you could also use a catalog (or in Word XP or later, a directory) type mailmerge with the mergefields inside the cells of a one row table in the mailmerge main document. Then when you execute the merge, the data from each record will be inserted into a row in a table that is created. -- Please respond to the Newsgroup for the benefit of others who may be interested. Questions sent directly to me will only be answered on a paid consulting basis. Hope this helps, Doug Robbins - Word MVP "_Mario_" wrote in message ... "Graham Mayor" wrote in message ... The following may help you on your way: Documents.Open ("d:\path\filename.csv") Selection.WholeStory Selection.ConvertToTable Separator:=wdSeparateByCommas End Sub That seems to be usefull... but what do U think about creating a Excell app. that load the csv, select all cells and then paste them imto the word doc? Mario |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
In typing dates in Word, i.e. "January 12" how do you keep the "1. | Microsoft Word Help | |||
word xp crashes after macros are recorded | Microsoft Word Help | |||
WP Delay Code - Word Equiv | Microsoft Word Help | |||
Continuous breaks convert to next page breaks | Microsoft Word Help | |||
macro in word | Microsoft Word Help |