paste keeping formatting

Discussion in 'Word Programming' started by Walter Briscoe, Jul 30, 2011.

  1. 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
    anything.

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

    I've hunted again and <http://www.ehow.com/how_2190263_paste-special-
    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
    dNewBlankDocument
    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. ;)
    --
    Walter Briscoe
     
    Walter Briscoe, Jul 30, 2011
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. kph
    Replies:
    0
    Views:
    142
  2. prasanta

    Copy and paste events

    prasanta, Aug 13, 2005, in forum: Word Programming
    Replies:
    0
    Views:
    144
    prasanta
    Aug 13, 2005
  3. JethroUK©

    Paste Special>Picture?

    JethroUK©, Sep 6, 2005, in forum: Word Programming
    Replies:
    7
    Views:
    193
    JethroUK©
    Sep 7, 2005
  4. IainH124A

    Automating Cut and Paste Special?

    IainH124A, Sep 12, 2006, in forum: Word Programming
    Replies:
    3
    Views:
    171
    Jonathan West
    Sep 12, 2006
  5. delphis96 via OfficeKB.com

    Copy Paste from IE to Word(2003), re-style text, maintain formatting

    delphis96 via OfficeKB.com, Oct 12, 2006, in forum: Word Programming
    Replies:
    4
    Views:
    270
    delphis96 via OfficeKB.com
    Oct 19, 2006
  6. braz

    Copy-paste office documents via clipboard

    braz, Mar 22, 2007, in forum: Word Programming
    Replies:
    1
    Views:
    344
    JensB
    Mar 30, 2007
  7. Supriya

    How to copy row and paste

    Supriya, May 22, 2007, in forum: Word Programming
    Replies:
    2
    Views:
    140
    digbydog
    May 30, 2007
  8. agraashish
    Replies:
    1
    Views:
    445
    agraashish
    Sep 29, 2009
Loading...