I'm getting an exception in my vb.net project:
System.Runtime.InteropServices.COMException (0x800A1492): You cannot paste this selection into a table. at Microsoft.Office.Interop.Word.Range.Paste()
The code is:
Code:
bookmark.Select()
_WordApplication.ActiveDocument.SetCompatibilityMode(Microsoft.Office.Interop.Word.WdCompatibilityMode.wdWord2013)
_WordApplication.Selection.Copy()
_WordApplication.Selection.MoveStart()
_WordApplication.Selection.MoveUp(Unit:=Word.WdUnits.wdLine, Count:=1)
_WordApplication.Selection.Range.Paste()
_WordApplication.Selection.Paste()
Bookmark is a table in word-template. The idea is to read values from SQL-database and insert several rows to table in word-document. I have tried with different versions of Microsoft.Office.Interop.Word.dll with no success.
This code works in older WIN7-environments but not in all WIN10-environments. In some WIN10-environment it works OK.
Any idea what could be wrong?