Import Data from Excel Table to Word Table- word 2003

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Import Data from Excel Table to Word Table- word 2003

Post by Stefan_Sand »

Hi all,

i have some preformatted tables in a word document with some data in it; some people of my project team always send me their updated Data in an excel, where i have always the task to copy the data the right way. As the tables in Excel have the same form in Word: how is it possible via VBA to import the data i want into my word table/tables (as is want). The data exchange out from excel is not as easy as data exchange into excel....
I don´t want to copy the data everytime by hand...

i attached a word file with the tables in it and added the excel file into it, i get per month


your help will be appreciated,
stefan

ps: by the way, hi Hans!!!
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Import Data from Excel Table to Word Table- word 2003

Post by HansV »

Hi Stefan,

Welcome to Eileen's Lounge!

Do you want to import all the "tables" from the Excel workbook into a Word document?
Do all the tables start with "WHEN"? (I notice that they don't all end the same: some have "From WHOM" in the last row, while others have "Notes")
Best wishes,
Hans

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: Import Data from Excel Table to Word Table- word 2003

Post by Stefan_Sand »

the structure in excel corresponds to the word table (they are exact copies) - they corespond to their word originals;in the excelfile you have the whole list of the communication matrices in it; in my word doc i only copied one table to show how one table is formatted.
I want to import the data selectively (?). Is this possible??

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Import Data from Excel Table to Word Table- word 2003

Post by HansV »

Does that mean that you'd like to be able to choose from a list? If so, what should the list display? For example, the value from column C in the first row of each "table"?
Best wishes,
Hans

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: Import Data from Excel Table to Word Table- word 2003

Post by Stefan_Sand »

that is correct (if thats not too difficult to get)

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Import Data from Excel Table to Word Table- word 2003

Post by HansV »

I'll see what I can come up with.
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Import Data from Excel Table to Word Table- word 2003

Post by HansV »

The easiest way would be to copy a "table" in the Excel workbook and paste it into the Word document. No code, no hassle.

If you prefer to automate it, see the attached zip file. The Word document contains a macro ImportFromExcel that will open a userform. It'll ask you to select the workbook; it will then populate the list box with the available "tables". Select one and click Import.

Note: you'll have to make sure that the first column of each table is shaded correctly - the code has to find out some way where the table ends, and I chose the shading.

You'll want to clean up the formatting of the imported table, I'll leave that to you.
DataMatrix.zip
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: Import Data from Excel Table to Word Table- word 2003

Post by Stefan_Sand »

may i call it the wow - factor???

k, i´m testing it and play for a while... ;-)) :cheers:

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: Import Data from Excel Table to Word Table- word 2003

Post by Stefan_Sand »

ok, i tried to test it in office 2003 , but it seems, that the macro seems to need an excel 2007 sheet, eh?
it can´t open excel files before office 2007;

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Import Data from Excel Table to Word Table- word 2003

Post by HansV »

Change "*.xls?" to "*.xls".
Best wishes,
Hans

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: Import Data from Excel Table to Word Table- word 2003

Post by Stefan_Sand »

ok, but then i get the application or objectoriented error message... might there be a problem with my multilanguage german office?

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Import Data from Excel Table to Word Table- word 2003

Post by HansV »

Does this version work better? I used late binding instead of early binding.

If you still get error messages, please try to find out where they arise.
DataMatrix.zip
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: Import Data from Excel Table to Word Table- word 2003

Post by Stefan_Sand »

ok, now i can decide which table to import, the only thing then happens is the mixture of the tableformat after importing the tables; but this seems to be normal in word.... (one of the reasons, i like excel that much)
cheers,
stefan

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Import Data from Excel Table to Word Table- word 2003

Post by HansV »

It's perfectly possible to create good-looking tables in Word, but the tables in the Excel workbook haven't been created with copying to Word in mind...
Best wishes,
Hans

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: Import Data from Excel Table to Word Table- word 2003

Post by Stefan_Sand »

ok, i understand, thanks for your support. ;-)

ps: its that late in the Nederlands right now???

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Import Data from Excel Table to Word Table- word 2003

Post by HansV »

Stefan_Sand wrote:ps: its that late in the Nederlands right now???
Sorry, what do you mean?
Best wishes,
Hans

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: Import Data from Excel Table to Word Table- word 2003

Post by Stefan_Sand »

i meant your shown system time as a joke. ;)

User avatar
HansV
Administrator
Posts: 78416
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Import Data from Excel Table to Word Table- word 2003

Post by HansV »

Do you mean the time beneath my user picture? That's the date and time I joined Eileen's Lounge.
Or did you mean something else?
Best wishes,
Hans

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: Import Data from Excel Table to Word Table- word 2003

Post by Stefan_Sand »

yes, thats what i meant, overseen in a few moments....