0
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
32
33
34
35
36
37
| | Private Sub Main
sRet = InputBox("置換パターンを入力してください", "簡易複数行置換マクロ", "s/置換前/置換後/gi")
If Left(sRet, 2) <> "s/" Then Exit Sub
iStart = 3
iEnd = InStr(iStart, sRet, "/")
If iStart >= iEnd Then Exit Sub
sBefore = Mid(sRet, iStart, iEnd - iStart)
iStart = iEnd + 1
iEnd = InStr(iStart, sRet, "/")
If iStart > iEnd Then Exit Sub
sAfter = Mid(sRet, iStart, iEnd - iStart)
Set oRegExp = New RegExp
iStart = iEnd + 1
If Instr(iStart, sRet, "g") Then oRegExp.Global = True
If Instr(iStart, sRet, "i") Then oRegExp.IgnoreCase = True
oRegExp.Pattern = sBefore
If GetSelectedString(CLng(0)) = "" Then SelectAll
InsText CStr(oRegExp.Replace(GetSelectedString(CLng(0)), sAfter))
Set oRegExp = Nothing
End Sub
Call Main
|