Imports Word = Microsoft.Office.Interop.Word Imports System.Runtime.InteropServices Dim oWord As Word.Application Dim oDoc As Word.Document oWord = CreateObject("Word.Application") oDoc = oWord.Documents.Open("Test.doc") oWord.Visible = False oDoc.SpellingChecked = False oWord.ScreenUpdating = False oWord.CheckLanguage = False oDoc.GrammarChecked = False oWord.AutoCorrect.CorrectCapsLock = False oWord.AutoCorrect.CorrectDays = False oWord.AutoCorrect.CorrectHangulAndAlphabet = False oWord.AutoCorrect.CorrectInitialCaps = False oWord.AutoCorrect.CorrectKeyboardSetting = False oWord.AutoCorrect.CorrectSentenceCaps = False
sReplace = "AbCD" ofind = oWord.Selection.Find For Each oPara1 In oWord.ActiveDocument.Paragraphs myRange = oPara1.Range Dim str1 As String = oPara1.Range.Text Dim str2 As String = Midstr(str1)'remove space form string If str2 <> Nothing Then bResult = IsUnicode(str2) If bResult = True Then Else With ofind .ClearFormatting() .Text = str2 .Replacement.ClearFormatting() .Replacement.Text = sReplace .MatchCase = True .MatchWholeWord = True .Wrap = Word.WdFindWrap.wdFindContinue .Execute(Replace:=Word.WdReplace.wdReplaceAll) End With End If End If oWord.Selection.MoveDown(Unit:=Word.WdUnits.wdParagraph, Count:=1) Next
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)