Bryan Carbonnell
carbonnb at sympatico.ca
Sun May 16 10:25:29 CDT 2004
On 14 May 2004 at 14:43, Andy Lacey wrote: > can do it manually but can't for the life of me see how to do it in > code. The selection object has a Text property, but you can't Copy > that, and even if you could I don't know what that would do with the > embedded merge field. Can someone (Bryan for example?) help? Where am > I going wrong. I always have this kind of trouble with Word Basic, > it's a nightmare unless you've got an example to work from. I don't use mail merge very often. I don't like it. So I may not be the best person to help :( I can duplicate what you are describing, but I can't select just the text. It's quite bizare. Tick, tock. Tick, Tock.... Well now after messing around some more I have a solution. What you need to do is reduce the range's size by 1 chartacter, which takes the cell marker out of the rang that you will be copying. Here's some code to show what I mean(and as always watch for wrap): Sub test() Dim doc As Document Dim cl As Cell Dim rngCL As Range Dim pasteDoc As Document 'Get the document with the table Set doc = ActiveDocument 'Get the Cell Set cl = doc.Tables(1).Cell(1, 2) 'Set the range to the cell Set rngCL = cl.Range 'Move the range's end point back one rngCL.End = rngCL.End - 1 'Now copy rngCL.Copy 'Get the doc where you will paste into Set pasteDoc = Documents.Add 'Paste pasteDoc.Range.Paste 'Close and release objects Set pasteDoc = Nothing Set cl = Nothing Set rngCL = Nothing Set doc = Nothing End Sub -- Bryan Carbonnell - carbonnb at sympatico.ca I don't suffer from insanity, I enjoy every minute of it.