@tumik I have received your sample documents and code via private message. Your test documents have bookmarks with the same name. MS Word document cannot contain bookmarks with duplicated names. So after appending documents the duplicated bookmarks are renamed - _0
suffix is added. For example see the following code:
Document doc1 = new Document(@"C:\Temp\Test01.docx");
Document doc2 = new Document(@"C:\Temp\Test02.docx");
Console.WriteLine("=============First Document Bookmarks===============");
foreach (Bookmark bk in doc1.Range.Bookmarks)
Console.WriteLine(bk.Name);
Console.WriteLine("=============Second Document Bookmarks===============");
foreach (Bookmark bk in doc2.Range.Bookmarks)
Console.WriteLine(bk.Name);
// Merge documents
doc1.AppendDocument(doc2, ImportFormatMode.UseDestinationStyles);
Console.WriteLine("=============Result Document Bookmarks===============");
foreach (Bookmark bk in doc1.Range.Bookmarks)
Console.WriteLine(bk.Name);
The output of this code is the following:
=============First Document Bookmarks===============
AccountNumber
IDNumber
Surname
FirstName
Nationality
RelIdNo
passcountry
permitno
PostalAddress
SuburbPost
CityPost
PostcodePost
PhysicalAddress
Suburb
City
Postcode
BusinessTelNo
CellPhoneNo
relationship
CardRequired
=============Second Document Bookmarks===============
AccountNumber
FirstName
Surname
IDNumber
CIS
ClientType
Occupation
BusinessTelNo
Employer
NonResStatus
PhysicalAddress
Suburb
Postcode
PostalAddress
SuburbPost
PostcodePost
=============Result Document Bookmarks===============
AccountNumber
IDNumber
Surname
FirstName
Nationality
RelIdNo
passcountry
permitno
PostalAddress
SuburbPost
CityPost
PostcodePost
PhysicalAddress
Suburb
City
Postcode
BusinessTelNo
CellPhoneNo
relationship
CardRequired
AccountNumber_0
FirstName_0
Surname_0
IDNumber_0
CIS
ClientType
Occupation
BusinessTelNo_0
Employer
NonResStatus
PhysicalAddress_0
Suburb_0
Postcode_0
PostalAddress_0
SuburbPost_0
PostcodePost_0
As you can see AccountNumber
, FirstName
, Surname
, IDNumber
, BusinessTelNo
, PhysicalAddress
, Suburb
, Postcode
, PostalAddress
, SuburbPost
, PostcodePost
bookmarks from the second document have been renamed after appending documents.