Jacco Posted November 16, 2009 Share Posted November 16, 2009 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.$OSOURWORDAPP.Selection.WholeStory $OSOURWORDAPP.Selection.Copy _WordDocClose($OSOURWORDDOC, 0) $ODESTWORDAPP = _WordAttach($SDESTFILENAME, "FileName") $ODESTWORDAPP.Selection.EndKey(6) $ODESTWORDAPP.Selection.InsertBreak(2) $ODESTWORDAPP.Selection.PasteSo far I have tried the following variants of the pastespecial without succes$ODESTWORDAPP.Selection.PasteSpecial(2) $ODESTWORDAPP.Selection.PasteSpecial(0,0,0,0,2) $ODESTWORDAPP.Selection.PasteSpecial(0,false,0,false,2) $ODESTWORDAPP.Selection.PasteSpecial.DataType = 2 (wouldn't compile) $ODESTWORDAPP.Selection.PasteAndFormate(22)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.Regards,Jacco Link to comment Share on other sites More sharing options...
Juvigy Posted November 16, 2009 Share Posted November 16, 2009 Try this one: $ODESTWORDAPP.Selection.PasteSpecial() Also did you try if it works if you do the same manually? Sometimes the paste special function in Word/Excel stops working. Link to comment Share on other sites More sharing options...
Jacco Posted November 18, 2009 Author Share Posted November 18, 2009 (edited) 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", "") Later! Edited November 18, 2009 by Jacco Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now