title: Removing Workbook External Link Sources Using ClosedXML
body: <p>I'm trying to remove any external link sources in a workbook using closedXML. I'm very new to using ClosedXML so forgive me if the answer is very obvious. I'm rewriting some of my Interop code to ClosedXML. I currently have a working code for interop as shown below.</p>
  <pre><code>    Public Shared Sub Remove_External_Links(wbName As String)
  
      Dim xlApp As Excel.Application
      Dim WB As Excel.Workbook
  
      xlApp = GetObject(, Constants.ExcelApp)
      WB = xlApp.Workbooks(wbName)
  
      With WB
          Try
              For Each Link In WB.LinkSources(Type:=Excel.XlLinkType.xlLinkTypeExcelLinks)
                  .ChangeLink(Link, WB.Name, Excel.XlLinkType.xlLinkTypeExcelLinks)
              Next
          Catch ex As Exception
          End Try
      End With
  
  End Sub
  </code></pre>
  <p>This code below is what I currently have for ClosedXML but not sure how to complete it.</p>
  <pre><code>    Public Shared Sub Remove_External_Links(wbName As String)
  
      Dim XMLwb As XLWorkbook = New XLWorkbook(wbName)
      Dim XMLws As IXLWorksheet
  
      With XMLwb
          Try
  
              For Each XMLws In XMLwb.Worksheets
                  For Each Link In XMLws.Hyperlinks
  
                    'NOT SURE WHAT TO ADD IN HERE. ALSO NOT SURE IF HYPERLINKS IS CORRECT.
  
                  Next Link
              Next XMLws
  
          Catch ex As Exception
          End Try
      End With
  
  End Sub
  </code></pre>
  <p>Hoping someone can help with this.
  Thanks in advance.</p>