I get the same error message and I’m not using bookmarks. Environment is VB.Net and Aspose.Word 3.1.7
I have a simple test document and I’m trying to mail merge in 2 passes from 2 different data tables.
The template has 3 simple fields at the top followed by a repeating set of fields in a repeating region as per the Aspose documentation.
For the test, I invoke the 2 passes individually with 2 different buttons. The merge works fine on the first pass, but throws the “Attempted to clone a by reference attribute ‘16’…” exception on the second pass.
The order in which the passes are invoked makes no difference. The first merge always works and the second merge always fails.
I tried different combinations of MailMerge.Execute(DataTable) and MailMerge.ExecuteWithRegions(DataTable) but get the same result.
As long as I call the mailmerge execution methods one after the other without any other Aspose methods in between, the merge works. If I insert a call such as the Save() method in between the two merge executions, I get the exception.
I am getting the same error. Here is the stack trace ->
Exception: System.Exception Message: Attempted to copy a by reference attribute ‘16’, but the attribute does not expose the complex attribute interface. Source: Aspose.Word at ?.?.?(Int32 ?) at ?.?.?() at Aspose.Word.DocumentBuilder.?(? ?, Boolean ?) at Aspose.Word.DocumentBuilder.MoveTo(Node node) at Aspose.Word.DocumentBuilder.?(? ?) at Aspose.Word.DocumentBuilder.MoveToMergeField(String fieldName)
The error is occurring when i call ‘builder.MoveToMergeField(fieldName);’
Unfortunately, I don’t have the luxury as ijoubert because my code is too complicated. Dmitry, please help!
Please attach the problematic document so we can reproduce the issue. And could you also specify the name of the merge field which is passed to builder.MoveToMergeField that throws?
I’ve attached the form per your request. The name of the field it was occurring on is ‘Title’. I’ve determined that if I use MSWord to delete the bad fields and then recreate them, the problem seems to go away. I have many documents, so I was hoping I wouldn’t have to do this for all of them.
Also, this problem seems to be intermittent. I have two development boxes, both are the same setup, one sees the problem every time and the other isn’t affected. Also, our staging environment works fine, but it fails in production.
I have rolled back to v2.3 and it is working fine in all environments.
This worked beautifully before the upgrade. Now it appears to ignore the section the bookmark resides, instead it starts deleting sections from the top of the document one by one.
Initially I had been navigating to sections by ordinal, but of course when you delete one, all the ordinals get updated and this became a nightmare to manage.
Help! Thanks!
p.s. sorry the text of the post is so big, im setting it to arial size 1, but it comes out massive
in fact stepping through the code, and doc.Saving, everything is fine up until exactly the same point as the error was happening before
basically after the last bookmark / section on page 6 “Assessment Centre”, i try to access the first bookmark on page 7 “ServiceFee” and delete it and this deletes my first page
in code ive deleted loads of sections (which in turns deletes some pages), ill attach all 3 files, before, before problem and after problem
i’ve had to delete the attachment because i saw it hyperlinked. its quite sensitive. will post to word@aspose.com as alastair_todd_files.zip
It seems that ‘before prob’ and ‘after prob’ docs are interchanged, because ‘after prob’ has the ‘Hudson Proposal’ section and ‘before prob’ doesn’t. In my test the lines
db.MoveToBookmark(“ServiceFee”);
db.CurrentParagraph.ParentSection.Range.Delete();
correctly remove the section containing the “ServiceFee” bookmark and I have tested on all three files.
My guess of what is happening is that you sometimes try to move to bookmark contained in section that was already removed. As a result DocumentBuilder position is not moved.
Consequently, executing DocumentBuilder.CurrentParagraph.ParentSection.Range.Delete() leads to the removal of the section pointed by previous position of DocumentBuilder which depends of your previous actions with DocumentBuilder.
To check this supposition try to insert the Bookmark existence check, like