長いので説明は次のエントリーを参照。
...
Dim app
Set app = CreateObject("InDesign.Application.CS2_J")
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
Dim pageObj
Dim cont, flag, all_len,show_len,all_text,show_text,over_text
Dim i,j,BtnCode, eachTMP
cnt = 0
flag = true
Set pageObj = app.activeDocument.AllPageItems
for each eachTMP in pageObj
if typename(eachTMP) = "TextFrame" then
if (eachTMP.overflows) then 'あふれているかどうか?
cnt = cnt+1 '文字あふれをカウント
if (flag) then 'フレームを表示するか?
eachTMP.select() 'フレームの選択
WshShell.SendKeys "%^-" 'ショートカットキーの送信
call slp(10000) '表示切替待ち
all_len = len(eachTMP.ParentStory.contents) '全文字数を取得
show_len = len(eachTMP.contents) '表示されている文字数を取得
all_text = eachTMP.parentStory.contents '全テキスト内容を取得
over_text = mid(all_text, show_len+1, (all_len-show_len+1)) 'あふれている部分を取得
over_text = ReplaceText(over_text, chr(13), "¶"& chr(13)) '改行マークを追加
if eachTMP.Id <> eachTMP.PreviousTextFrame.Id then
over_text = "【!】連結フレームの場合はあふれた内容を表示できません"
end if
BtnCode = WshShell.Popup("【あふれた内容】" & chr(13) & chr(13) & over_text & chr(13) & chr(13) & chr(13) & chr(13) & "【次の文字あふれフレームを表示しますか?】",0,"文字あふれ発見",4+32+4096)
if BtnCode = 7 then flag = false
end if
end if
end if
next
if (cnt = 0) then
BtnCode = WshShell.Popup("文字あふれはありません", 0, "ドキュメント全体の検索完了" , 0+64+4096)
else
BtnCode = WshShell.Popup("全部で " & cnt & " 個の文字あふれフレームが存在します", 0, "ドキュメント全体の検索完了" , 0+64+4096)
end if
Function ReplaceText(str1, patrn, replStr)
Dim regEx
Set regEx = New RegExp ' 正規表現を作成
regEx.Pattern = patrn ' パターンを設定
regEx.IgnoreCase = True ' 大文字と小文字を区別しないように設定
regEx.Global = True ' 文字列全体を検索
ReplaceText = regEx.Replace(str1, replStr) ' 置換
End Function
sub slp(cnt)
for j=1 to cnt
j = j
next
end sub
0 件のコメント:
コメントを投稿