Merging DOCM documents

Home Forums Open-Xml-PowerTools Merging DOCM documents

This topic contains 4 replies, has 2 voices, and was last updated by  troessler 8 years, 7 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #3354

    troessler
    Participant

    Hi,

    I wanted to merge DOCM documents but I got an error saying “Not a Wordprocessing document”. I guess it is not supported at the moment. Is that correct?

    Thanks!

    #3355

    Eric White
    Keymaster

    Hi,

    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

    #3356

    troessler
    Participant

    Hi 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.
    Tobi

    #3357

    Eric White
    Keymaster

    Hi 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

    #3358

    troessler
    Participant

    Hi 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

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.