Rename a column

J

jamiechen168

Hello,

I inserted a database field to my word doc with data from .csv file. Am
I able to change the name of column to make the column header more
meaningful?

Test.doc =
.....
{ DATABASE \d "C:\\Temp\\Data.csv" \c "" \s "SELECT OrderItem_id,
OrderItem_price FROM C:\\Temp\\Data.csv" \l "3" \b "191" \h }

As you know, Word will display above as a table with 2 columns,
"OrderItem_id" and "OrderItem_price" for the column header. Is there a
way I can change the column header's text to something else?

I tried to change the select statement to become ".... SELECT
OrderItem_Id as ID...." but it didn't work either.

Please help.
 
D

Doug Robbins - Word MVP

You will need to change the names of the fields in the .csv file.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
P

Peter Jamieson

For a .csv file in Word 2003 (and possibly Word 2002, you can try this:

Create a file in c:\\temp called t.udl, e.g. using Notepad. It doesn't have
to have anything in it.

Use the following DATABASE field:

{ DATABASE \d "C:\\Temp\\t.udl" \c "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\temp\\;Mode=Share Deny None;Extended Properties=\"HDR=YES;\";Jet
OLEDB:Engine Type=96;" \s "SELECT OrderItem_id as ID,
OrderItem_price FROM Data.csv" \l "3" \b "191" \h }

If you have spaces in your alias name (e.g. "Item ID") or file name , quote
the name using backquotes `` or square brackets [ ] but not straight quotes
'' or \"\".

e.g.

{ DATABASE \d "C:\\Temp\\t.udl" \c "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\temp\\;Mode=Share Deny None;Extended Properties=\"HDR=YES;\";Jet
OLEDB:Engine Type=96;" \s "SELECT OrderItem_id as [item ID],
OrderItem_price FROM Data.csv" \l "3" \b "191" \h }

Peter Jamieson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top