Jump to content
Sign in to follow this  

Word PasteSpecial method

Recommended Posts


Hi everyone,

I am currently working on a script that copies content from one word file to the other. I am however only interested in the unformatted text, headers and different text layout is not good if this gets copied as well.

I know that there exists such a function, namely: PasteSpecial. Also the PasteAndFormat method looks promising. But after several attempts I am unable to properly do this.

This is a bit of the (working) code at the moment, it uses the regular paste method instead.

_WordDocClose($OSOURWORDDOC, 0)

So far I have tried the following variants of the pastespecial without succes

$ODESTWORDAPP.Selection.PasteSpecial.DataType = 2 (wouldn't compile)

Please note that the corresponding wdPasteText and wdFormatPlainText are 2 and 22 respectivly.

I have the feeling I am pretty close here, but can't seem to nail it down.

Thanks in advance. Any help is welcome.



Share this post

Link to post
Share on other sites

Try this one:


Also did you try if it works if you do the same manually?

Sometimes the paste special function in Word/Excel stops working.

Share this post

Link to post
Share on other sites

hi Juvigy,

Thanks for the reply! The code you suggested does work, but does nothing special, it is just like a regular paste now. I however have found out that headers are only copied if the source document has more than one section. Doing a simple find & replace removes all the sections. When it is then copied no header and footer information isn't copied with anymore. This more than sufficient for me.

_WordDocFindReplace($OSOURWORDDOC, "^b", "")


Edited by Jacco

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this