DNG - Cross reference link translation for RPE export
We can do cross reference links in DNG from a word in artifactA to a heading artifactB using edit artifactA->select word->add link->no traceability link to the heading artifactB in another part of the module.
When we export that module to Word using RPE the cross reference hyperlink appears in the Word document but it is a hyperlink back to the ArtifactB in the DNG database.
We want the cross reference to be translated into a Word cross reference to the heading representing artifactB in the exported word doc.
Is this possible?
606
Accepted answer
You can use a post processing macro that processes external hyperlinks and turn them into internal hyperlinks to bookmarks (to heading artifacts). First, you can add bookmarks for Headings so that on clicking the cross reference link, you will be taken to the heading artifact.
Sub processHyperlinks()
'Processes external hyperlinks to RRC and turns them into internal Word hyperlinks to bookmarks with the
'address I<requirement artifact item id>
Dim oHyperLink As Hyperlink
For Each oHyperLink In ActiveDocument.Hyperlinks
' MsgBox ("Subaddress=" & ActiveDocument.Hyperlinks(counter).SubAddress & "Address=" & ActiveDocument.Hyperlinks(counter).address & "Name=" & ActiveDocument.Hyperlinks(counter).name & "TextToDisplay=" & ActiveDocument.Hyperlinks(counter).TextToDisplay)
oHyperLink.Range.Select
Dim address As String
address = oHyperLink.address
Dim index As Integer
index = InStr(address, "/resources/")
If index > 0 And address <> oHyperLink.TextToDisplay Then
Dim name As String
name = "I" + Right(address, Len(address) - index - 10)
Dim display As String
display = oHyperLink.TextToDisplay
If display <> "" Then ActiveDocument.Hyperlinks.Add Anchor:=oHyperLink.Range, SubAddress:=name, TextToDisplay:=display
End If
Next oHyperLink
End Sub
'Processes external hyperlinks to RRC and turns them into internal Word hyperlinks to bookmarks with the
'address I<requirement artifact item id>
Dim oHyperLink As Hyperlink
For Each oHyperLink In ActiveDocument.Hyperlinks
' MsgBox ("Subaddress=" & ActiveDocument.Hyperlinks(counter).SubAddress & "Address=" & ActiveDocument.Hyperlinks(counter).address & "Name=" & ActiveDocument.Hyperlinks(counter).name & "TextToDisplay=" & ActiveDocument.Hyperlinks(counter).TextToDisplay)
oHyperLink.Range.Select
Dim address As String
address = oHyperLink.address
Dim index As Integer
index = InStr(address, "/resources/")
If index > 0 And address <> oHyperLink.TextToDisplay Then
Dim name As String
name = "I" + Right(address, Len(address) - index - 10)
Dim display As String
display = oHyperLink.TextToDisplay
If display <> "" Then ActiveDocument.Hyperlinks.Add Anchor:=oHyperLink.Range, SubAddress:=name, TextToDisplay:=display
End If
Next oHyperLink
End Sub