Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

word vba table

Status
Not open for further replies.

eHanSolo

Technical User
May 24, 2004
260
GB
hi all,

i've a table with 4 rows and 2 columns. In each of the rows or 'cells'(1st column), there is a number: 1.1, 1.2, 1.3 and 1.4

I'd like to do a search for say '1.2' and then copy the entire row and paste it in to a separate word document.

So i could end up with two word documents; one with 1.1, 1.2. The other word doc would have 1.3 and 1.4

Once separated I'd like to enter some text in column 2 and then merge the two docs back in to a single document again.

is this possible?

Any hints, tips or pointers would be greatly appreciated!

thank you in advance!!!

e
 
Once separated I'd like to enter some text in column 2 and then merge the two docs back in to a single document again.

is this possible?
Sure, it is possible.

But....WHY??????? Why split them...enter text...and merge them back together?? What is the point to this?

Also, you need to clarify something.
I'd like to do a search for say '1.2' and then copy the entire row and paste it in to a separate word document.

So i could end up with two word documents; one with 1.1, 1.2. The other word doc would have 1.3 and 1.4
The first paragraph describes a search for 1.2 and copying the row into a new document. The second paragraph describes this new document as including 1.1.

You must be precise.

Gerry
My paintings and sculpture
 
sure no probs.

I basically made a refernce to the word object library and then i used a combination of code i found on the web and also the record macro feature in word to do what i wanted to do. way to go.

I can split a very large word doc made up of a large table in to smaller word docs (specific parts for specific people in my case) and then it gets sent out. Once completed, i've written another macro that pieces it all back to a single big doc again. It's quite cool.

only problem i'm facing at the moment is when i'm trying to merge it back to a single doc. the 'pastespecial' method pastes all the formatting i want but it's using the default table widths etc... still trying to figure out how i can change this.

i'm currently looking at this:

With targDoc
.PageSetup.TopMargin = 18
.PageSetup.BottomMargin = 72
.PageSetup.LeftMargin = 36
.PageSetup.RightMargin = 36
.PageSetup.GutterPos = wdGutterPosLeft
End With

The above is ok and when you use 'pastespecial' for the first time it works fine and it uses the new page setup vals. however, subsequent pastespecials pastes table rows with a smaller (default) widths... so it looks a bit odd.

any ideas guys?

best,

e
 
If you are using Word 2002 or later, you may want to consider making a table with a Table Style. In which case, the table will always be formatted by the definition of the style.

Gerry
My paintings and sculpture
 
hey fumei,

i've sorted it out. the following does actually work. It was so darn simple... all i had to do was use pastespecial and then do the page setup bit... INSTEAD of setting the borders etc first!

hope this helps anyone using word/excel!

'use this after you've pasted stuff... works well and a lot simpler!
With targDoc
.PageSetup.TopMargin = yourVal
.PageSetup.BottomMargin = yourVal
.PageSetup.LeftMargin = yourVal
.PageSetup.RightMargin = yourVal
.PageSetup.GutterPos = yourVal
End With


best,

e
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top