Merging DOCM documents
Home › Forums › Open-Xml-PowerTools › Merging DOCM documents
- This topic has 4 replies, 2 voices, and was last updated 9 years, 10 months ago by
troessler.
-
AuthorPosts
-
April 21, 2016 at 8:54 am #3355
Eric White
KeymasterHi,
You are correct, it is not a supported feature. For this to be supported, would require deciding how to incorporate macros from multiple documents, and I’m not sure how well that would work, or whether that would be a good idea.
I would take the approach of converting to DOCX (stripping out the macros), do the merging, and then put the macros back in, making it a DOCM again. I have never written this code, but would be a matter of copying over some binary parts, creating parts with correct content types, and creating correct relationships, and probably changing the content type for the main document part. Then can change back to a DOCM, and the macros should work.
-Eric
April 21, 2016 at 9:18 am #3356troessler
ParticipantHi Eric,
thanks for your quick response. And I fully agree. At the moment I also don’t know if it is a good idea. Currently we are using version 2.2.0 because we are still on .NET 4.0. But when using this version I directly get an exception (Not a Wordprocessing document) when using the WmlDocument class.
I checked in a test project version 4.1.3. which is requireing .NET 4.5. And here I was able to combine two DOTM files but the Macros were not taken into account. I have to check now if it is ok to wait until we have migrated to .NET 4.5 and use OpenXmlPowerTools to combine the files without the Macros.
Thanks.
TobiApril 21, 2016 at 10:04 am #3357Eric White
KeymasterHi Tobi,
Question: if you don’t mind sharing, what is your ‘use case’? What user story do you need to enable?
Sometimes there are better solutions than using macros (but sometimes not). Generating documents that contain macros would trigger that ‘Better do a full threat analysis’ response, as in the book “Writing Secure Code“.
I am pretty enthused about the new JavaScript add-in model for Office. You can do a lot with it.
-Eric
April 21, 2016 at 10:49 am #3358troessler
ParticipantHi Eric,
in our Software we generate reports and use your component to combine different word documents (one per record). It is working good because we use only DOCX files. Now we also want to support DOCM files. They can contain any Macro and there is no special use case. It really depends on the customer needs. We just want to support this.
I guess I will check if it is possible to generate more than one report (one for each record).
Thanks!
Tobi -
AuthorPosts
- You must be logged in to reply to this topic.