.net - Office Word Interop issue caused by Microsoft Update -


I have a problem in a windows form application written in VB.Net (I did not want to write it, troubleshooting it To try). Part of the application uses the Word Interop assembly to merge mail between a Word document and a text file containing the data.

A update was made for Microsoft Word a few days ago, due to the fact that the mail merge was stopped working. Word document prints only with no data, I am stumped about what I can do to resolve this issue.

I tried to run the application as an administrator, I tried to copy the interop DLL directly into the project folder, but neither of the differences actually thought that what actually And did not know what to try). The only thing to work was to actually uninstall the update, but it is going to happen again next week with the next round of automatic updates. The code for the mail merge is below, any advice would be greatly appreciated, I do not even know where to start the issue, where to start. Word documents and data files are located in both AppData folders

  wordApp.Documents.Open (filename: = returnAppPath () & "mergedoc.doc") wordApp.ActiveDocument.MailMerge .. OPENDATASOURCE (Name: = _ returnAppPath () & amp; "inputdata.txt", _ ConfirmConversions: = False, ReadOnly: = False, LinkToSource: = True, _ AddToRecentFiles: = False, PasswordDocument: = "", PasswordTemplate: = "", _ WritePasswordDocument: = "", WritePasswordTemplate: = "", undo: = false, _ format: = WordkWdOpenFormatkwdOpenFormatAuto, connection: = "", SQLStatement: = "", SQLStatement1 _: = "" , Subtype: = Word.WdMergeSubType.wdMergeSubTypeOther) with WordApp.ActiveDocument.MailMerge. Dirtination = Word.WdMailMergeDestination.wdSendToNewDocument.SuppressBlankLines = True.DataSource with.First Record = Word.WdMailMergeDefaultRecord.wdDefaultFirstRecord.LastRecord = Word.WdMailMergeDefaultRecord.wdDefaultLastRecord End with .Execute (Stop: = False) with end inches as integer end = CInt (numudCopies.Value) wordApp.Application.PrintOut (FileName: = "", category = WordkWdPrintOutRangekwdPrintAllDocument, item: = _ Word.WdPrintOutItem.wdPrintDocumentContent, copies: = CObj (intCopies), Pages = "" page type = WordkWdPrintOutPageskwdPrintAllPages, _ ManualDuplexPrint: = false, collate: = true, background = true, PrintToFile: = _ false, PrintZoomColumn = 0, PrintZoomRow = 0, PrintZoomPaperWidth = 0, _ PrintZoomPaperHeight: = 0) wordApp.ActiveWindow.Close (false) wordApp.ActiveDocument.Close (SaveChanges: = Word.WdSaveOptions.wdDoNotSaveChanges) wordApp .Quit () wordApp = Nothing  
After the

Interop is not a good idea under certain circumstances (see Microsoft's KB 257757).

One option I n Your scenario is to reconstruct a template and merge mail to mergify the program by using some OpenXml toolkits. In this way, you will get many benefits:

  • Data can be prepared using the add-in for placeholders in the template word
  • The last document will be in the DOCX, Which can be used in 2003 with all versions of the office
  • You can merge the data in all parts of the document (including header, footer, sections)
  • conditional criteria Data can be shown / omitted on the basis.
  • Report generation can be centered on a server, no word installation is necessary.

Yours In the NET application, you will need to read the data in the .NET object (for archive data model sections) and then send them in the document generation method that prepares the final document where the templates and the data are merged together. For this, the device of my choice is Docentric and since I started using it, I did not have to do any more plain word mail merging or VBA document scripts for complex document hard work. You can see a closer look at the practical example.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -