Excelã®ãã¯ããå¤é¨ã«å¸ãåºãã¦ä¿åããããããï¼WSH/JScriptã§ï¼VBAã®ã½ã¼ã¹ã³ã¼ãã ããæãåãï¼
Excelããï¼VBAã®ã³ã¼ããå¸ãåºããããã
ã¢ã¸ã¥ã¼ã«ãã¨ã«ï¼ï¼ã¢ã¸ã¥ã¼ã«åï¼.basãã®ååã§ä¿åãããã
以ä¸ã®ã¹ã¯ãªãããå®è¡ããã°ããã
vacuum_vba.js
/* Excelãããã¯ãã®å ¨ã¢ã¸ã¥ã¼ã«ãå¤é¨ã«å¸ãåºãããã */ // excelã®ãã¡ã¤ã«åã¨ï¼ã¢ã¸ã¥ã¼ã«ã®å¸åºãå ãã¹ãæå® var file_dir = "D:\\temp"; var file_name = "hoge.xls"; var file_path = file_dir + "\\" + file_name; var vacuum_dir = file_dir + "\\macros"; // ããã¯ãéã var excel = WScript.CreateObject("Excel.Application"); excel.Visible = true; excel.Workbooks.Open( file_path ); var book = excel.Workbooks( excel.Workbooks.Count ); // JScript/WSH ã§ï¼Excelãã¡ã¤ã«ãèªã¿æ¸ãããã // http://language-and-engineering.hatenablog.jp/entry/20090717/p1 // ããã¯å ã®ãã¯ãã®å ¨ã¢ã¸ã¥ã¼ã«ãã¹ãã£ã³ãã var cnt_module = 0; var e = new Enumerator( book.VBProject.VBComponents ); for( ; ! e.atEnd() ; e.moveNext() ) { // ã¢ã¸ã¥ã¼ã«ãåå¾ var vba_module = e.item(); // ãã®ã¢ã¸ã¥ã¼ã«ã®ååãåå¾ var module_name = vba_module.Name; //WScript.Echo( module_name ); // ãã®ã¢ã¸ã¥ã¼ã«ã®ã¨ã¯ã¹ãã¼ãå ãã¹ãæ±ºå® var bas_path = vacuum_dir + "\\" + module_name + ".bas"; // ãã®ã¢ã¸ã¥ã¼ã«ãã¨ã¯ã¹ãã¼ã vba_module.Export( bas_path ); cnt_module ++; } // Excelãéãã¦çµäº excel.DisplayAlerts = false; excel.Quit(); excel = null; WScript.Echo( file_name + " ããï¼å ¨ " + cnt_module + " åã®ã¢ã¸ã¥ã¼ã«ã " + vacuum_dir + " ä¸ã«å¸ãåºãã¾ããã" );
ä¿åå ãã©ã«ãã¯ãããããä½ã£ã¦ãããã¨ã
ã¾ãï¼Excelä¸ã§ï¼äºåã«ä¸è¨ã®è¨å®ãè¡ãªã£ã¦ãããã¨ã
(Excel2003ã®å ´å)
ãã¼ã«ï¼ãã¯ãï¼ã»ãã¥ãªãã£ï¼ä¿¡é ¼ã§ããçºè¡å ï¼Visual Basic ããã¸ã§ã¯ãã¸ã®ã¢ã¯ã»ã¹ãä¿¡é ¼ãããããªã³
(Excel2007ã®å ´å)
ãªãã³ã®ãéçºãã¿ãï¼ãã¯ãã®ã»ãã¥ãªãã£ï¼VBAããã¸ã§ã¯ããªãã¸ã§ã¯ãã¢ãã«ã¸ã®ã¢ã¯ã»ã¹ãä¿¡é ¼ãã
http://support.microsoft.com/kb/282830/ja
â»ãããã°ã©ãã³ã°ã«ããVisual Basicããã¸ã§ã¯ãã¸ã®ã¢ã¯ã»ã¹ã¯ä¿¡é ¼æ§ã«æ¬ ãã¾ããã¨ããã¨ã©ã¼ã¡ãã»ã¼ã¸ãåºãªãããã«ãªãã
ã½ã¼ã¹ã³ã¼ãã®è§£èª¬ï¼
JScriptã§ã®Enumeratorã®ä½¿ãæ¹ã«ã¤ãã¦
ã³ã¬ã¯ã·ã§ã³ãEnumeratorãªãã¸ã§ã¯ãï¼VBScriptã®For Eachã®ãããï¼
http://www.imasy.or.jp/~hir/hir/tech/...
JScript 8.0 Enumerator ãªãã¸ã§ã¯ã
http://msdn.microsoft.com/ja-jp/libra...
ãã¯ãã®ã¨ã¯ã¹ãã¼ãã«ã¤ãã¦
ã¢ã¸ã¥ã¼ã«ãã¦ã¼ã¶ã¼ãã©ã¼ã ãã¨ã¯ã¹ãã¼ãããã«ã¯ï¼
http://excelfactory.net/excelvbatips/...
VBProject.VBComponentsã®åè¦ç´ ãExportãã
è£è¶³
ä¸è¨ã®ã¨ã³ããªã§ã¯ï¼VBAã®ã³ã¼ããSVNãªã©ã®ãã¼ã¸ã§ã³ç®¡çãã¼ã«ã§ç®¡çããããããããã®ä¸ææ³ãè¿°ã¹ãã
å 容ã¯ï¼
- å¤é¨ã³ã¼ããExcelã«èªåçã«åãè¾¼ã
ã¨ããäºã«ç¦ç¹ããã¦ã¦ããã
Excel VBAã®ãã¯ããï¼è¤æ°ã®ããã¯ããå©ç¨ããæ¹æ³ ï¼æ¨æºã¢ã¸ã¥ã¼ã«ãããã¯ã®å¤é¨ã§ç®¡çãã¦ï¼å ±éã©ã¤ãã©ãªã¨ãã¦èªã¿è¾¼ã¿ï¼
http://language-and-engineering.hatenablog.jp/entry/20090731/p1
ä»åã®ã¨ã³ããªã¯ï¼ãã®éã ã
- Excelããå¤é¨ã«ã³ã¼ããèªåçã«å¸ãåºã
ã¨ããäºããããã¨ãã¦ããã
ãããªãï¼æ¢åã®Excelãã¡ã¤ã«ã«æãå ãããã¨ãªãï¼å¥åã®ãç£è¦å¯¾è±¡ãï¼ç®¡ç対象ï¼ãè¨ãããã¨ãå¯è½ã«ãªãã
ã