Appreciate your assistance with changing the following subroutine so it uses Aspose.Word instead of Microsoft.Office.Interop.Word
Public Shared Sub UpdateMergeFields(ByRef path As String)
Try
if string.Empty.Equals(Configuration.ConfigurationSettings.AppSettings("UpdateMergeFields") & "")
exit Sub
End If
Dim app As ApplicationClass
Dim doc As DocumentClass
Try
If Not System.IO.File.Exists(path) Then
Exit Sub
End If
doc = app.Documents.Open(path)
doc.ComputeStatistics(WdStatistic.wdStatisticPages)
If doc.Sections.Count > 0 Then
doc.Sections(1).Headers(WdHeaderFooterIndex.wdHeaderFooterEvenPages).Range.Fields.Update()
doc.Sections(1).Headers(WdHeaderFooterIndex.wdHeaderFooterFirstPage).Range.Fields.Update()
doc.Sections(1).Headers(WdHeaderFooterIndex.wdHeaderFooterPrimary).Range.Fields.Update()
End If
doc.Range.Fields.Update()
doc.Save()
Catch
' ignore error
Finally
If Not doc Is Nothing Then
doc.Close()
End If
If Not app Is Nothing Then
app.Quit()
End If
End Try
Catch ex As Exception
' ignore error
End Try
End Sub