한글 버전과 상관없이 컴퓨터에 따라 매크로가 정확히 작동을 안합니다.(같은 문제가 2번씩 추출이 되고 지정된 문제가 정확히 추출이 안됩니다.) 어떤 문제가 있는지 알고 싶네요.
var mun_cnt=1;
MovePos(2,0,0);//문서 맨앞이동
var mun_last=0;
var s;
function OnScriptMacro_문항추출복사()
{
//OnScriptMacro_미주폰트3에흰색처리(); // 미주가 흰색처리 되어있을경우 주석처리시 속도 향상
//OnScriptMacro_뒤쪽미주앞으로복사(); //미주가 앞쪽에 있을경우 주석처리 속도 향상
OnScriptMacro_책갈피넣기();
OnScriptMacro_문항복사();
}
function OnScriptMacro_책갈피넣기()
{
var hc=HeadCtrl;
do{
if(hc.CtrlID==“en”){
HAction.GetDefault(“Goto”, HParameterSet.HGotoE.HSet);
with (HParameterSet.HGotoE)
{
HSet.SetItem(“DialogResult”, 31);
SetSelectionIndex = 5;
}
HAction.Execute(“Goto”, HParameterSet.HGotoE.HSet); //다음 미주찾기
HAction.GetDefault(“Bookmark”, HParameterSet.HBookMark.HSet);
with (HParameterSet.HBookMark)
{
Name = mun_cnt.toString();
Command = 0;
}
HAction.Execute(“Bookmark”, HParameterSet.HBookMark.HSet);//책갈피넣기
mun_cnt++;
MovePos(23,0,0);//한글자 뒤로 이동
}
hc=hc.Next;
}while(hc)
mun_last=mun_cnt-1;
mun_cnt=1;
}
function OnScriptMacro_책갈피로문제블럭지정(cnt)
{
for(var i=0 ; i<2 ; i++) //한번에 지정 책갈피 못가는 버그, 문제 번호가 맞지 않을경우 2를 더 늘려줌
{
HAction.GetDefault(“Bookmark”, HParameterSet.HBookMark.HSet);
with (HParameterSet.HBookMark)
{
Name=cnt.toString();
Command = 1;
}
HAction.Execute(“Bookmark”, HParameterSet.HBookMark.HSet);//책갈피이동
HAction.Run("Cancel");
HAction.Run("Select");
if(cnt==mun_last)
{
MovePos(3,0,0); //문서끝이동
MovePos(22,0,0); //그줄앞으로이동
MovePos(13,0,0); //한글자 앞으로 이동
}
else
{
HAction.GetDefault("Bookmark", HParameterSet.HBookMark.HSet);
with (HParameterSet.HBookMark)
{
Name=(cnt+1).toString();
Command = 1;
}
HAction.Execute("Bookmark", HParameterSet.HBookMark.HSet);//책갈피이동
MovePos(13,0,0);
}
}
}
function expStr(match, p1, p2){
var temp=“z”;
var end=parseInt(p2)+1;
for(i=p1;i<end;i++){temp=temp+“,”+i;}
return temp.substring(2);
}
function OnScriptMacro_문항복사(){
str=prompt(“출력할 범위를 지정해주세요 예)1, 3, 5-7”, “출력범위지정”);
str=str.replace( /\s/g, “”);
str=str.replace( /(\d+)-(\d+)/g, expStr);
var arr=eval(“[”+str+“]”);
makeNewTab();
for(var item in arr){
OnScriptMacro_책갈피로문제블럭지정(arr[item]);
HAction.Run(“Copy”);
HAction.Run(“WindowNextTab”);
setDan();
HAction.Run(“Paste”);
HAction.Run(“WindowNextTab”);
}
}
function NewTabExist()
{
var result;
HAction.Run(“WindowNextTab”);
if(Path==“”)
result = 1;
else
result = 0;
HAction.Run(“WindowNextTab”);
return result;
}
function makeNewTab()
{
if(!NewTabExist())
{
HAction.Run(“FileNewTab”);
HAction.Run(“WindowPrevTab”);
}
}
function setDan(){
HAction.GetDefault(“MultiColumn”, HParameterSet.HColDef.HSet);
with (HParameterSet.HColDef)
{
Count = 1;
SameGap = MiliToHwpUnit(8.0);
LineType = HwpLineType(“Solid”);
LineWidth = HwpLineWidth(“0.12mm”);
HSet.SetItem(“ApplyClass”, 524);
HSet.SetItem(“ApplyTo”, 2);
}
HAction.Execute(“MultiColumn”, HParameterSet.HColDef.HSet);
}
function OnScriptMacro_블럭저장(s)
{
var act=CreateAction(“FileSaveBlock_S”);
var set=act.CreateSet();
act.GetDefault(set); set.SetItem(“FileName”, s);
set.SetItem(“Format”, “HWP”);
ret=act.Execute(set);
}
function OnScriptMacro_책갈피지우기()
{
var cc=HeadCtrl;
do{
if(cc.CtrlID==“bokm”){ // 블럭 책갈피일 경우 %bmk 추가
DeleteCtrl(cc);//북마크제거
}
cc=cc.Next;
} while(cc)
}
function OnScriptMacro_뒤쪽미주앞으로복사()
{
OnScriptMacro_책갈피넣기();
for(var i=1 ; i<=mun_last ; i++)
{
HAction.GetDefault(“Goto”, HParameterSet.HGotoE.HSet);
with (HParameterSet.HGotoE)
{
HSet.SetItem(“DialogResult”, 31);
SetSelectionIndex = 5;
}
HAction.Execute(“Goto”, HParameterSet.HGotoE.HSet);
HAction.Run(“MoveSelRight”);
HAction.Run(“Cut”);
HAction.GetDefault(“Goto”, HParameterSet.HGotoE.HSet);
with (HParameterSet.HGotoE)
{
HSet.SetItem(“DialogResult”, 29);
SetSelectionIndex = 5;
}
HAction.Execute(“Goto”, HParameterSet.HGotoE.HSet);
HAction.Run(“Paste”);
}
OnScriptMacro_책갈피지우기();
}
function OnScriptMacro_미주폰트3에흰색처리()
{
OnScriptMacro_책갈피넣기();
for(var i=1 ; i<=mun_last ; i++)
{
HAction.GetDefault(“Goto”, HParameterSet.HGotoE.HSet);
with (HParameterSet.HGotoE)
{
HSet.SetItem(“DialogResult”, 31);
SetSelectionIndex = 5;
}
HAction.Execute(“Goto”, HParameterSet.HGotoE.HSet);
HAction.Run(“MoveSelRight”);
HAction.GetDefault(“CharShape”, HParameterSet.HCharShape.HSet);
with (HParameterSet.HCharShape)
{
FontTypeUser = FontType(“TTF”);
FontTypeSymbol = FontType(“TTF”);
FontTypeOther = FontType(“TTF”);
FontTypeJapanese = FontType(“TTF”);
FontTypeHanja = FontType(“TTF”);
FontTypeLatin = FontType(“TTF”);
FontTypeHangul = FontType(“TTF”);
TextColor = RGBColor(255, 255, 255);
Height = PointToHwpUnit(3.0);
}
HAction.Execute(“CharShape”, HParameterSet.HCharShape.HSet);
HAction.Run(“Cancel”);
HAction.Run(“MoveLineEnd”);
}
OnScriptMacro_책갈피지우기();
}
function alert(s, flag)
{
if ( flag === undefined ) flag = 1;
XHwpMessageBox.String=s;
XHwpMessageBox.Flag=flag;
XHwpMessageBox.DoModal();
return XHwpMessageBox.Result;
}
function prompt(prompt, title) {
if ( prompt === undefined ) prompt = ‘’;
if ( title === undefined ) title = ‘’;
var script = new ActiveXObject(‘MSScriptControl.ScriptControl’);
script.language = ‘vbscript’;
return script.eval(‘inputbox("’ + prompt + ‘“,”’ + title + ‘")’);
}