Hi i have tried to translate your c# code in vb via an online translator but there is 1 line with errors if you can please take a look thank you for your support.
The line is :
Public Sub InsertDocumentAtBookamrk(ByVal bookmarkName As String, ByVal MainDoc As Document, ByVal MargedDoc As Document)
'Create DocumentBuilder
Dim builder As DocumentBuilder = New DocumentBuilder(MainDoc)
'Move cursor to bookmark and insert paragraph break
builder.MoveToBookmark(bookmarkName, False, True)
'builder.MoveToBookmark(bookmarkName);
builder.Writeln()
'Content of srcdoc will be inserted after this node
Dim insertAfterNode As Node = builder.CurrentParagraph.PreviousSibling
'Content of first paragraph of srcDoc will be apended to this parafraph
Dim insertAfterParagraph As Paragraph = CType(insertAfterNode, Paragraph)
'Content of last paragraph of srcDoc will be apended to this parafraph
Dim insertBeforeParagraph As Paragraph = builder.CurrentParagraph
'We will be inserting into the parent of the destination paragraph.
Dim dstStory As CompositeNode = insertAfterNode.ParentNode
'Get list if current paragraph is list item
Dim list As List = Nothing
Dim listFontColor As Color = Color.Black
If insertAfterParagraph.IsListItem Then
list = insertAfterParagraph.ListFormat.List
listFontColor = insertAfterParagraph.ListFormat.ListLevel.Font.Color
End If
'Loop through all sections in the source document.
For Each srcSection As Section In MargedDoc.Sections
'Loop through all block level nodes (paragraphs and tables) in the body of the section.
For Each srcNode As Node In srcSection.Body
'Do not insert node if it is a last empty paragarph in the section.
Dim para As Paragraph = CType(srcNode, Paragraph)
'If current paragraph is first paragraph of srcDoc
'then appent its content to insertAfterParagraph
If ((Not (para) Is Nothing) AndAlso para.Equals(MargedDoc.FirstSection.Body.FirstParagraph)) Then
Dim dstParagraph As Paragraph = CType(MainDoc.ImportNode(para, True, ImportFormatMode.KeepSourceFormatting), Paragraph)
While dstParagraph.HasChildNodes
'Node dstNode = MainDoc.ImportNode(node, true, ImportFormatMode.KeepSourceFormatting);
insertAfterParagraph.AppendChild(dstParagraph.FirstChild)
End While
If (Not insertAfterParagraph.IsListItem AndAlso dstParagraph.IsListItem) Then
If (list Is Nothing) Then
list = dstParagraph.ListFormat.List
End If
insertAfterParagraph.ListFormat.List = list
listFontColor = para.ListFormat.ListLevel.Font.Color
End If
'If subdocument contains only one paragraph
'then copy content of insertBeforeParagraph to insertAfterParagraph
'and remove insertBeforeParagraph
If MargedDoc.FirstSection.Body.FirstParagraph.Equals(MargedDoc.LastSection.Body.LastParagraph) Then
While insertBeforeParagraph.HasChildNodes
insertAfterParagraph.AppendChild(insertBeforeParagraph.FirstChild)
End While
insertBeforeParagraph.Remove()
End If
End If
'If current paragraph is last paragraph of srcDoc
'then appent its content to insertBeforeParagraph
If ((Not (para) Is Nothing) AndAlso para.Equals(MargedDoc.LastSection.Body.LastParagraph)) Then
Dim tofix As Node
Dim previouseNode As Node = Nothing
For Each node As Node In para.ChildNodes
Dim dstNode As Node = MainDoc.ImportNode(node, True, ImportFormatMode.KeepSourceFormatting)
If (previouseNode Is Nothing) Then
'insertBeforeParagraph.InsertBefore(dstNode, insertBeforeParagraph.FirstChild);
tofix = insertBeforeParagraph.InsertBefore(dstNode, insertBeforeParagraph.FirstChild)
Else
'insertBeforeParagraph.InsertAfter(dstNode, previouseNode);
tofix = insertBeforeParagraph.InsertAfter(dstNode, previouseNode)
End If
previouseNode = dstNode
' If last paragraph to be inserted is not numbering, then remove Numbering
If (Not para.IsListItem AndAlso CType(dstNode.ParentNode, Paragraph).IsListItem) Then
CType(tofix.ParentNode, Paragraph).ListFormat.RemoveNumbers()
End If
' Apply numbering according to the collected List
insertBeforeParagraph.ListFormat.List = list
Next
' insertBeforeParagraph.ListFormat.List = list;
Else
'This creates a clone of the node, suitable for insertion into the destination document.
Dim newNode As Node = MainDoc.ImportNode(srcNode, True, ImportFormatMode.KeepSourceFormatting)
'Set list if it is needed
If (newNode.NodeType = NodeType.Paragraph) Then
If (CType(newNode, Paragraph).IsListItem AndAlso (Not (list) Is Nothing)) Then
CType(newNode, Paragraph).ListFormat.List = list
End If
End If
'Insert new node after the reference node.
dstStory.InsertAfter(newNode, insertAfterNode)
insertAfterNode = newNode
End If
Next
Next
'Clear formating of list
If (Not (list) Is Nothing) Then
For Each level As ListLevel In list.ListLevels
level.Font.Color = listFontColor
level.Font.Bold = False
level.NumberPosition = 0
Next
End If
End Sub