Word PasteAndFormat

Add-in Express™ Support Service
That's what is more important than anything else

Word PasteAndFormat
Copy from DocA to DocB and retaining formating. 
manhhoang.nguyen nguyen




Posts: 7
Joined: 2008-09-22
Hi,
I have 2 Word documents A and B.
I want to copy from A and paste to B and retain the formatting from A.
I can do so in Word's Macro:
Selection.PasteAndFormat(wdFormatOriginalFormatting)
However, I couldn't find that method exposed in the object model of Add-in-Express's WordApp or an alternative way to do so in Add-in-Express.
Please help.
Thanks alot.
Posted 26 Sep, 2008 08:09:08 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Manhhoang,

The PasteAndFormat method was introduced in Office XP. That is why you are not able to use it. You may try to use version specific interop assemblies.

.NET, Extended MAPI, Windows Phone & RT
Posted 26 Sep, 2008 08:37:29 Top
manhhoang.nguyen nguyen




Posts: 7
Joined: 2008-09-22
Thank you,
While creating the add-in project using the Add-In-Express .NET Wizard, I select "Use Primary Interop Assemblies" option. Now, I can see that method.
Is that correct way to do. Any pros-cons about changing from "Use verion-neutral interop assemblies" to above option?

Posted 27 Sep, 2008 01:09:42 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Manhhoang,

PIAs (Primary Interop Assemblies) provide the compiler with early-binding information on the host application objects, their properties, and methods. In Visual Basic 6 terms, PIAs correspond to references you set using the Project / References dialog. Office applications are almost 100% backward compatible and you can use PIAs from an earlier Office version to work with a newer one. Say, you can develop your add-in using Outlook 2000 PIA and it will work with Outlook 2007. Note, in this case, you can access Outlook 2007 features using late binding (see the InvokeMember method in MSDN). Obviously, you cannot expect the add-in developed with Outlook 2007 PIA to work with Outlook 2000: say Outlook 2000 (as well as Outlook XP and Outlook 2003) does not have the Explorer.Search event specified in Outlook 2007 PIA.

.NET, Extended MAPI, Windows Phone & RT
Posted 27 Sep, 2008 05:46:56 Top