■ 아래 한글의 텍스트를 대체하는 방법을 보여준다.
▶ 예제 코드 (VB)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
'-------------------------------------------------- ' 아래 한글 텍스트 대체하기 '-------------------------------------------------- ' pHwpCtrl : HwpCtrl OCX ' strSource : 소스 문자열 ' strReplace : 대체 문자열 '-------------------------------------------------- Public Sub ReplaceText(pHwpCtrl As HwpCtrl, strSource As String, strReplace As String) Dim pHwpAction As HwpAction Dim pHwpParameterSet As HwpParameterSet Set pHwpAction = pHwpCtrl.CreateAction("AllReplace") Set pHwpParameterSet = pHwpAction.CreateSet() pHwpParameterSet.SetItem "FindString", strSource ' 찾을 문자열 pHwpParameterSet.SetItem "ReplaceString", strReplace ' 대체 문자열 pHwpParameterSet.SetItem "IgnoreMessage", True ' 메시지 무시 여부 pHwpParameterSet.SetItem "Direction", 2 ' 찾을 방향 : 앞(0), 뒤(1), 전체(2) pHwpParameterSet.SetItem "SeveralWords", True ' 복수 단어 찾기 여부 pHwpAction.Execute pHwpParameterSet Set pHwpAction = Nothing Set pHwpParameterSet = Nothing End Sub |