exception SEHException
Imports Word = Microsoft.Office.Interop.Word Dim sFind As String Dim sReplace As String sFind = "findme" sReplace = "findyou" Dim oWord As Word.Application Dim oDoc As Word.Document Try oWord = CreateObject("Word.Application") oDoc = oWord.Documents.Open("E:\test1.docx") oDoc.Activate() Dim myStoryRange As Microsoft.Office.Interop.Word.Range For Each myStoryRange In oDoc.StoryRanges With myStoryRange.Find .Text = sFind .Replacement.Text = sReplace .Wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue .Execute(Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll) End With Next myStoryRange oDoc.SaveAs("E:\test2.docx") oDoc.Close() oDoc = Nothing oWord.Application.Quit() oWord = Nothing Catch ex As Exception MessageBox.Show("Error accessing Word document.") End Try End Sub
SEHException
ExternalException.ErrorCode
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)