Ref objFalse, // SaveChanges ref objMissing, // OriginalFormat ref objMissing // RouteDocument StrCopy, // FileName ref objTarget, // MergeTarget ref objMissing, // DetectFormatChanges ref objUseFormatFrom, // UseFormattingFrom ref objMissing // AddToRecentFilesĭebug.WriteLine( " The active document is " + objDocLast.Name) ĭebug.WriteLine( " Closing " + objDocBeforeLast.Name) Ref objOrgDoc, // FileName ref objMissing, // ConfirmVersions ref objMissing, // ReadOnly ref objMissing, // AddToRecentFiles ref objMissing, // PasswordDocument ref objMissing, // PasswordTemplate ref objMissing, // Revert ref objMissing, // WritePasswordDocument ref objMissing, // WritePasswordTemplate ref objMissing, // Format ref objMissing, // Enconding ref objMissing, // Visible ref objMissing, // OpenAndRepair ref objMissing, // DocumentDirection ref objMissing, // NoEncodingDialog ref objMissing // XMLTransformĭebug.WriteLine( " Merging file " + strCopy)
Object objUseFormatFrom = WdUseFormattingFrom.wdFormattingFromSelected Object objTarget = WdMergeTarget.wdMergeTargetSelected boxing of default values for COM interop purposes object objMissing = Missing.Value / public void Merge( string strOrgDoc, string arrCopies, string strOutDoc) / /// /// File names of the modified files
The upload logic in the web page is quite straightforward: It creates a unique name for the changed document (I did this trick with Guid.NewGuid()), and then it stores the file in the "Copies" folder.Ĭopy Code /// /// Merge a document with a set of copies
The initial version is published in the server with the "Track Changes" option turned on, so every change the user does will be easily recognized. The web form is fairly simple and allows downloading the original document, uploading a modified version and creating the output document. In a nutshell, the Default.apsx page is the front end, the DocMerger performs the actual merging and the documents are located in the "files" folder ("OriginalDoc" contains the original version of the document, "Copies" is where all the uploaded files from the users reside, and "Output" is the folder in which the summarized document is generated). In order to implement a solution, I built a C# ASP.NET project in Visual Studio. Of course, such feature could be used by means of VBA automation hence, it's also available in.
Then, the administrator would be able to see a summarized document with the changes introduced by all the users, allowing him to approve or reject them in a change-by-change basis.Īlthough I saw it quite difficult at first glance, digging deeper into the documentation, I found that besides the "track changes" feature in Word is also possible to merge several documents into a final one, so that all changes will be available in a single document. In my current project, the customer wants a set of features that will allow the administrator to publish a document in a website, let users work in that document (either changing it or adding comments) and submit the modified version back to the site.