#module
*xlerror
xlQuit
dialog "エラーが発生した為、終了します", 1
end
#deffunc xlInit int hide
onerror *xlerror
newcom xlApp, "Excel.Application"
xlApp("Visible") = (hide = 0)
xlApp("DisplayAlerts") = 0
xlBooks = xlApp("WorkBooks")
return
#deffunc xlNew
xlBook = xlBooks("Add")
return
#deffunc xlQuit
if vartype(xlSheet) = vartype("comobj") : delcom xlSheet
if vartype(xlBook) = vartype("comobj") : delcom xlBook
if vartype(xlBooks) = vartype("comobj") : xlBooks -> "Close" : delcom xlBooks
if vartype(xlApp) = vartype("comobj") : xlApp -> "Quit" : delcom xlApp
return
#deffunc xlSelSheet str shname
xlSheet = xlBook("Worksheets", shname)
xlSheet -> "Select"
return
#deffunc xlAddSheet str shname, local s, local xlSheets
xlSheets = xlBook("Sheets")
xlSheets -> "Add"
xlSheet = xlBook("ActiveSheet")
if shname ! "" : xlSetSheetName shname, ""
return
#deffunc xlDelSheet str shname
if shname ! "" : xlSheet = xlBook("Worksheets", shname)
xlSheet -> "Delete"
return
#defcfunc xlGetSheetNum local xlSheets
xlSheets = xlBook("Sheets")
return xlSheets("Count")
#defcfunc xlGetSheetName int shno, local xlSheets
xlSheets = xlBook("Sheets")
xlSheet = xlSheets("Item", shno)
return xlSheet("Name")
#deffunc xlGetSheetNames array shname, local i
i = xlGetSheetNum()
repeat i
shname.cnt = xlGetSheetName(cnt + 1)
loop
return i
#deffunc xlSetSheetName str newname, str shname
if shname ! "" : xlSheet = xlBook("Worksheets", shname)
xlSheet("Name") = newname
return
#global
sdim sh, 16, 5
gsel 0, 2
mes "エクセル起動"
xlInit
xlNew
wait 100
mes "シート追加(シート名:ultimate)"
wait 100
xlAddSheet "ultimate"
wait 100
mes strf("シート(%s)を%sに変更", xlGetSheetName(2), "hspbc")
wait 100
xlSetSheetName "hspbc", xlGetSheetName(2)
wait 100
mes "シート(ultimate)削除"
wait 100
xlDelSheet "ultimate"
if xlGetSheetNum() >= 2 {
wait 100
mes strf("シート(%s)を選択", xlGetSheetName(2))
wait 100
xlSelSheet xlGetSheetName(2)
wait 100
}
mes "エクセル終了"
wait 100
xlQuit
wait 300
end
|