Clean document

A

Andy S

I'm sure this is a very simple problem and I think my vague knowledge
of the Word object model is the problem.

I need to strip some data from the tables in a word document and paste
the values into Excel. To do this I have recorded some macros and
combined them to remove blank lines, hard returns and headers/footers
etc.

When I run this combined macro I get all my tables, which are all the
same format (same number of colums) pushed up together and in a
perfect format for doing a; Select All,Copy & Paste in to Excel and
this works fine.

The only bits of data I can't remove are the text that people have
added to the document in between the tables. I'm sorry this might be
confusing, so in summary what I am tryiong to do is;

- Delete everything in the Word document except the tables . . . .
- Invoke Excel
- Select All
- Copy
- Switch to Excel
- Paste

any help would be gratefully recieved
 
J

Jonathan West

Andy S said:
I'm sure this is a very simple problem and I think my vague knowledge
of the Word object model is the problem.

I need to strip some data from the tables in a word document and paste
the values into Excel. To do this I have recorded some macros and
combined them to remove blank lines, hard returns and headers/footers
etc.

When I run this combined macro I get all my tables, which are all the
same format (same number of colums) pushed up together and in a
perfect format for doing a; Select All,Copy & Paste in to Excel and
this works fine.

The only bits of data I can't remove are the text that people have
added to the document in between the tables. I'm sorry this might be
confusing, so in summary what I am tryiong to do is;

- Delete everything in the Word document except the tables . . . .
- Invoke Excel
- Select All
- Copy
- Switch to Excel
- Paste

any help would be gratefully recieved

I would suggest a slightly different approach, copy each table in turn and
paste it

The code would be something like this

Dim oTable as Table
For each oTable in ActiveDocument.Tables
oTable.Range.Copy
'put your excel pasting code here
Next oTable
 

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