paste keeping formatting


Walter Briscoe

I run Microsoft Office Word 2003 (11.8328.8333) SP3.
I drive some VBA code from Microsoft Office Excel 2003 (11.8335.8333)
SP3. (I don't think that is relevant to solving my problem, but mention
it.) The VBA is Microsoft Visual Basic 6.5.

I have code which creates an extract from an input document.
I open the input document read only.
I open it again, empty it and save with the name of my output document.
I fill the output document by copying bookmarks from the input document
to the clipboard and pasting to the output document.
My pasted data is different in the output document.
I did some hunting and believe styles are applied to the pasted text,
thus changing it. I was advised that, in Word, ticking
Tools/Options/Edit/Show Paste Options buttons would produce a drop down
list beside the Paste icon so I could select keep original formatting
and then see what the macro recorder noted. I did not see that tick do

This is a stripped-down excerpt of my original code. I hope it clarifies
those words above:
Rd.Selection.GoTo What:=wdGoToBookmark, Name:=S

I've hunted again and <
microsoft-word.html> looks hopeful.
That allowed me to understand that the tools option above actually makes
a drop down list appears in the paste target document and suggests that
rather than Wr.Selection.Paste, I want
Wr.Selection.PasteAndFormat Type:=wdFormatOriginalFormatting
That does the same as Wr.Selection.Paste. i.e. What is written is
formatted differently from what is read by .Copy.

(I have since tried making the output document using
wr.Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=w
but the behavior remained unchanged.)

The sort of change I see is of font size and line spacing. I am fairly
sure it is a style issue, but have no knowledge of how to find out why
Word decides to change what is written. ;)

Unless someone here can cast light, I shall live with the irritation. ;)


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