Excelã®ãã¯ããã¢ããªã³ãªã©ãå©çšããéã«ããã䜿ã£ãŠã倧äžå€«ãªãã ããããšæ°ã«ãªãäºã¯ç¡ãã§ãããã?
ã§ã¯ãããªããšããæªããªãå®å šãªãã¯ããã¢ããªã³ãšã¯?ã©ã®ãããªã³ãŒãã£ã³ã¯ã«ãªãã®ã?ããšããçåã沞ããŠããã®ã§ãããMicrosoft ããã¥ã¡ã³ãã®äžãæ¢ããŠã¿ãŠããããã«çããŠãããããŒãžãèŠã€ããäºã¯ã§ããŸããã§ããã
ããã§ã·ãªãŒãºã§ãExcel VBAã³ãŒãã£ã³ã°ã®å®å šæ§ãã«ã€ããŠèããŠè¡ãäºã«ããŸããã
ä»åã¯ãEXEãã¯ãŒã¯ã·ãŒããªã©ã®äžã«é èœãããŠããã±ãŒã¹ãã³ãŒãã£ã³ã°èªäœããé èœãããŠããããããªã±ãŒã¹ã«ã€ããŠåãäžããŸãã
â»ååäºåããŸãããå€éšããååŸããŠãããã±ãŒã¹ã«ã€ããŸããŠã¯ãã€ã³ã¿ãŒãããããã®ããŒã¿ååŸãšããŠæ¬¡åã説æããããŸãã
â»åäœã¯32bitçExcel 2016ãš64bitçExcel 2021ã® ããŒãžã§ã³2304(ãã«ã 16327.20248)ã䜿çšããŠæ€èšŒããŠããŸãã
ã¯ãŒã¯ã·ãŒãã«ãã€ããªãŒãã¡ã€ã«ãæ ŒçŽããäºãã§ãã
å¥ã®èšäºã«ãªããŸãããExcel VBAã§ãã€ããªãŒãšãã£ã¿ãäœã(SHIFT-JISç·š)ããšãExcel VBAã§ãã€ããªãŒãšãã£ã¿ãäœã(UTF-8ç·š)ãã§ãã€ããªãŒãã¡ã€ã«ããã€ããªé åã«èªã¿èŸŒãã§ãã¯ãŒã¯ã·ãŒãäžã«16é²è¡šèšãããã³ãŒãã£ã³ã°äºäŸãšãããæžãåºãã³ãŒãã£ã³ã°äºäŸãã玹ä»ããŠããŸãã
åœè©²èšäºã¯ããã€ããªãŒãšãã£ã¿ããVBAã§å®è£ ããäºã趣æšãªã®ã§ããããããæªçšãããšæ§ã ãªåœ¢ã«å€ããŠãVBAã§ãã³ããªã³ã°ã§ããããŸããŸãªãªããžã§ã¯ãã«ãã€ããªãã¡ã€ã«ãæ ŒçŽããäºãã§ããŠããŸãäºãæå³ããŠããŸãã
åœç¶ããã®ããšã¯å±éºæ§ã®ãã話ã«ãªãã®ã§ãåœè©²èšäºã®äžã§ã泚æåèµ·ããããŠããã ããŠããŸãããExcelã§ã¯ããã®ãããªå±éºæ§ãçºèŠãåŠçœ®ããããã®ããŒã«ãããã¥ã¡ã³ãã®æ€æ»ããæäŸããŠãããŠããŸãã
ãªãããã®ããŒã«ã®æ å ±ã¯Microsoft 365ãµããŒãã®äžèšããŒãžã§èª¬æãããŠããŸãã
ãããã¥ã¡ã³ãã®æ€æ»ãã察象ã«ããŠãããã®ãã¹ãŠããçŽæ¥VBAã§ãã³ããªã³ã°ã§ããã?ãã¯æ£çŽè§£ã£ãŠã¯å± ãŸããããäŸãã°å¥èµ·åããããã»ã¹ããé èœãããŠããããŒã¿ãèªã¿åºãäºãã§ããã°ãããããã€ã³ã¿ãŒãããã«ã€ãªããã«ãªãã©ã€ã³ã§ãã£ãŠãæªæãããããŒã¿ãååŸã§ããŠããŸãã¯ãã§ãã
ãªãä»åã¯ããã©ãã«é ãã?ãã«ã€ããŠã®ã³ãŒãã£ã³ã°äºäŸã«ã¯è§Šããªãäºã«ããããŸãã
ãã®çç±ãšããŠã¯ãVBAã§æ±ãããªããžã§ã¯ãã®çš®é¡ã¯ããã€ããã察å¿çãšããŠã®ç¢ºèªãã€ã³ãã®æ°ãå¢ããŠããŸããããã§ãã
ãã®ãã次ã®ç« ã§ã¯ãå ¥ãå£ã§ã¯ãªãåºå£ãã«è©±ã移ããŸãã
VBAã§ãã€ããªããŒã¿ãæžãåºãæ¹æ³
ããã§ã玹ä»ããã®ã¯2ã€ã®æ¹æ³ã§ããã²ãšã€ã¯VBAã®Openã¹ããŒãã¡ã³ãã䜿çšããæ¹æ³ã§ãããäžã€ã¯Microsoft ActiveX Data Objects (ADO)ã®Streamãªããžã§ã¯ãã«ãªããŸãã
åŸè ã¯CreatObjecté¢æ°ã§åŒã³åºãäºãã§ããŸãããVisual Basic Editorã®åç §èšå®ããèšå®ããäºãåºæ¥ãŸãã
ãªãMicrosoft ActiveX Data Objects (ADO)ã®Streamãªããžã§ã¯ãã¯ãååã®èšäºãExcel VBAã³ãŒãã£ã³ã°ã®å®å šæ§ãšã¯ã(1)èŠç¹ãšåç §èšå®ããã®äžã®ãåç §èšå®ãšTypeLib(COMã¯ã©ã¹)ãã®ç« ã®ãè¯ã䜿ããããåç §å¯èœãªã©ã€ãã©ãª ãã¡ã€ã«ããã§äžçªæåã«äžããã©ã€ãã©ãªã§ãã
ãã ããããã以å€ã«ååšããªãã®ã?ããšèãããŠããçµæçã«ã¯ã䜿çšã®ããœã³ã³ã®äžã«ã©ã®ãããªCOM ã³ã³ããŒãã³ã(ãªããžã§ã¯ã)ãå°å ¥ãããŠããã?ã«ãã£ãŠã質åã«å¯Ÿããçãã¯å€ãã£ãŠããŠããŸãã®ã§æå®ããäºã¯ã§ããŸããã
ååãã説æããããŸããããæ¬ã·ãªãŒãºã§ãäŒãããŠãã®ã¯ãäžè¬çã«äœ¿ãããŠããã³ãŒãã£ã³ã°äºäŸã䜿ã£ãŠæªæã®ãã人ãæªæã®ããã³ãŒãã£ã³ã°ããããšããããã©ã®ãããªç¹ã«æ³šæãããªããã°ãªããªãã®ã?ããšããç¹ã«ãªããŸãã®ã§ãããããããå«ã¿çœ®ãããã ããã°å¹žãã§ãã
Openã¹ããŒãã¡ã³ãã䜿çšããæ¹æ³
ãã®ã³ãŒãã£ã³ã°äºäŸãExcel VBAã§ãã€ããªãŒãšãã£ã¿ãäœã(SHIFT-JISç·š)ãã§ã玹ä»ããŠããŸããå床æ²èŒããããŸãã
ãã€ããªãã¡ã€ã«ãæžãåºãããã®ãã¡ã³ã¯ã·ã§ã³ãšããŠå®è£ ããŠããŸããããããäºã§å®éã«æžåºãã®ããã«Openã¹ããŒãã¡ã³ãã䜿çšããç®æã¯1ã€ã«éçŽã§ããŸãããéã«ãã®ãŠãŒã¶é¢æ°ãWriteFileBianaryããã©ãã§åŒã³åºããŠããã?ã確èªããäºãå¿ èŠã«ãªããŸãã
- stFileNameåŒæ°
- æžãåºãæã®ãã¡ã€ã«åãã»ããããŸãã
- bytbufåŒæ°
- æžãåºããã€ããªããŒã¿ãæ ŒçŽãããã€ããªé åãã»ããããŸãã
Public Sub WriteFileBianary(stFileName As String, bytbuf() As Byte) Dim fn As Integer fn = FreeFile Open stFileName For Binary Access Write As #fn Seek #fn, LOF(fn) + 1& Put #fn, , bytbuf Close #fn End Sub
ADOã®Streamãªããžã§ã¯ãã䜿çšããæ¹æ³
å®ã¯ãã®æ¹æ³ã¯ãExcel VBAã§æåã³ãŒãè¡šãäœã(SHIFT-JISç·š)ãã®èšäºã®ãStreamãªããžã§ã¯ãã§æåã³ãŒãå€æãããã³ãŒãã£ã³ã°äºäŸãã§ãæåã³ãŒããSHIFT-JISã«ã¡ã¢ãªäžã§å€æããããã®ãŠãŒã¶é¢æ°ãšããŠã玹ä»ããŠããŸãã
ä»åã¯ãããã¡ã¢ãªäžã§ã¯ãªãããã€ããªãã¡ã€ã«åœ¢åŒã§ä¿åããããã®ãã¡ã³ã¯ã·ã§ã³ãšããŠäœãå€ããŠããŸãã
ãªãåŒæ°ã¯Openã¹ããŒãã¡ã³ãã®å Žåãšåãã«åãããŠããŸãã
Public Sub AdoWriteFileBianary(stFileName As String, bytAry() As Byte) Const ADTYPEBINARY As Integer = 1 Const ADTYPETEXT As Integer = 2 Const ADSAVECREATEOVERWRITE = 2 With CreateObject("ADODB.Stream") 'åŒæ°ã®ãã€ãé åãã¹ããªãŒã ã«ãã€ããªãŒã§æžã蟌ã .Type = ADTYPEBINARY .Open .Write bytAry 'åŒæ°ã§æå®ããããã€ãé åãã¹ããªãŒã ã«æžã蟌ã .SaveToFile stFileName, ADSAVECREATEOVERWRITE .Close End With End Sub
ããããã®æ¹æ³ã§ã©ãã確èªãã¹ãã?
ã説æãã2ã€ã®æ¹æ³ã§ç¢ºèªãã¹ãç¹ã¯ã€ãã®ããã«ãªããŸãã
â»äžã€ã®Noã«2è¡ä»¥äžããæã¯ãããããã®ãã€ã³ããèšå®å€ã確èªããå¿
èŠããããŸãã
No | æ¹æ³ | 確èªãã¹ããã€ã³ãã»èšå®å€ |
---|---|---|
1 | Open ã¹ããŒãã¡ã³ã | For Binary Access Write |
â»Accessã¯ãRead Writeãã«ãªãå Žåããã | ||
Put ã¹ããŒãã¡ã³ã | ãã€ããªããŒã¿ãæ ŒçŽãããã€ããªé åã®å€æ° | |
â»å€æ°ã«ã©ã®ãããªããŒã¿ãã»ããããŠããã®ã? | ||
2 | Type ãããã㣠| å€ãã1ã |
â»Streamå ã®ããŒã¿åãèšå®ããŠãã | ||
Write ã¡ãœãã | ãã€ããªããŒã¿ãæ ŒçŽãããã€ããªé åã®å€æ° | |
â»Streamå ã«ãã€ããªããŒã¿ãã»ãããã | ||
SaveToFile ã¡ãœãã | Streamå ã®ãã€ããªããŒã¿ããã¡ã€ã«ã«ä¿å | |
â»SaveOptionsã®ãã©ã¡ãŒã¿ 1:adSaveCreateNotExists(æ°èŠäœæ) 2:adSaveCreateOverwrite(æ°èŠäœæã»äžæžã) |
æ®å¿µãªãã確èªãã€ã³ãã ãã§ã¯äžåå
æªæã®ãã人ã¯ããã®ãããªç¢ºèªãã€ã³ããæãããšãã以å€ã®æ¹æ³ã§ãã€ããªããŒã¿ã«ããããšèããã¯ãã§ãã
äŸãã°16é²è¡šèšã®ãŸãŸã§ããã¹ããã¡ã€ã«ã«æžãåºããŠããããPowerShellãªã©ã§ãã€ããªå€æãããããããŸãã…è¿åããæ¹æ³ã¯ãããã§ãããã¯ãã§ãã
â»ãªãããã®ãããªå€éšã¢ããªã±ãŒã·ã§ã³ãèµ·åããå Žåã®è©±ã¯ã·ãªãŒãºã®äžã§ä»åŸåãäžããäºå®ã§ãã
çµå±ãäžçªç¢ºèªããªããã°ãªããªãäºã¯ãã©ã®ãããªããŒã¿ãæžèŸŒãããšããŠããã?ãã«ãªããšæããŸãããã§ãããããç解ããããã«ã¯ã³ãŒãã£ã³ã°ãèªã¿è§£ãå¿ èŠãããã®ã§ãããããªé¢åãããããšã¯ããããªããã®ã§ããã°ããã¡ã€ã«ãåºåãããããªã³ãŒãã£ã³ã°ãæžãããŠããã ãã§ãé»ãšå€å®ãããäºã«ãªã£ãŠããŸããããããŸããã
åŸã£ãŠãã©ãããŠãVBAã§ãã€ããªããŒã¿ãæžãåºãå¿ èŠãããå Žåã«ã¯ãã©ã®ãããªå 容ã®ããŒã¿ã«ãªãã®ã?ã解ãæãã³ãŒãã£ã³ã°ããŠçœ®ãå¿ èŠãããèªèã§ãã
ããã¯èšã£ãŠããååã§ããäŒãããŸãããã解ãæãæ§é ã§ãèªã¿æãã³ãŒãã£ã³ã°ã«ãªã£ãŠããã°å®å šãªã³ãŒãã£ã³ã°ã§ããããšã¯èšããªãã®ã§æ°ãæããŠã¯ãããŸããã
ç°¡åã«ã¯çããèŠã€ãããªãããããããã®è©±é¡ã¯é£ãç²æãããã®ã ãšæããŸãã
VBAã§ããã°ã©ã ã®ãœãŒã¹ã³ãŒããè¿œå ããã³ãŒãã£ã³ã°ã¯ã§ããã®ã?
ãã®ç« ããã¯ããœãŒã¹ã³ãŒãã®é èœãã®è©±ãããããŸãã
ãŸãæåã«ãçŸåšã¯ãããã¯ãããŠãããScriptControlãã«ã€ããŠã説æããŠçœ®ãããåããŸãã
ScriptControlã§åºæ¥ãäº
ä»ãåç §èšå®ãèŠããšåç §å¯èœãªã©ã€ãã©ãªãšããŠã¯åºãŠæ¥ãã®ã§ãããååã®èšäºã®ãè¯ã䜿ããããåç §å¯èœãªã©ã€ãã©ãª ãã¡ã€ã«ããã«ã¯ãScriptControlãã¯èŒããŠããŸããã
ãã®çç±ãšããŠã¯ãScriptControlãã¯ãMicrosoft Script Control 1.0ããšããã©ã€ãã©ãªåã§ååšã¯ããã®ã§ãããVBAã§ã¯å®éã«åŠçãããããã®ã¡ãœãããåäœããŠããªãããã§ãã
äŸãã°åç §èšå®ã§ãMicrosoft Script Control 1.0ããæå¹ã«ããŠããããªããžã§ã¯ã ãã©ãŠã¶ãŒ(Visual Basic Editorã®è¡šç€ºâãªããžã§ã¯ã ãã©ãŠã¶ãŒ)ã§ãMSScriptControlãã«ãã£ã«ã¿ãŒããŠèŠãŠã¿ããšãå·Šå³ã®ãããªã¡ãœãããååšããŠããäºãããããŸãã
ããããªããããRunãããExecuteStatementããªãšã®ã¡ãœãããå®è¡ããããšãããšãšã©ãŒãçºçããŸãã
ãä»ã¯äœ¿ããªãããšãã話ãå ã«ããŠããŸããŸãããããã®ã©ã€ãã©ãªã§ãäœãã§ããã?ããšãããšãaddcodeã¡ãœããã䜿ã£ãŠã¢ãžã¥ãŒã«ã«ãœãŒã¹ã³ãŒããåçã«è¿œå ããäºãã§ããŸããã
ãããŠããã®è¿œå ãããœãŒã¹ã³ãŒãããRunãããExecuteStatementããªã©ã®ã¡ãœããã§åããäºãã§ããã®ã§ããã
ãäœã®ããã«ãã®ãããªäºãããå¿ èŠããã£ãã®ã?ããæ¬æ¥ã®äœ¿çšç®çã¯è¯ãã¯è§£ããªãã®ã§ãããæªæã®ãã人ããããã°ãã³ãŒãã£ã³ã°ã ãèŠãŠãæªãåäœãããªããããªã®ã«âŠããšããããã«æªæã®ãããœãŒã¹ã³ãŒãã®å Žæãé èœããäºãã§ããŠããŸããŸããã
é èœå ã¯VBAã§æ±ãäºãã§ããæ§ã ãªãªããžã§ã¯ãã®äžã ã£ãããã€ã³ã¿ãŒãããäžããå ¥æããäºãã§ããã¯ãã§ãã
æ¯ãè¿ã£ãŠèãããšããæã¯ãæªæãããè¡çºãèªäœã«å¯ŸããŠã®ã¬ãŒããäœãã£ãããšãã話ã«ãªãã¯ã®ãããããŸããã
ã¢ãžã¥ãŒã«ãè¿œå ãã
ã§ã¯ãVBAã§ãåŸãããœãŒã¹ã³ãŒããè¿œå ããäºã¯ã§ããªãã®ã?ããšãããšããã©ã¹ãã»ã³ã¿ãŒ(ãããã¯ã»ãã¥ãªã㣠ã»ã³ã¿ãŒ)ã§ãéçºè åãã®ãã¯ãèšå®ããå€ããäºã§ã¢ãžã¥ãŒã«ãè¿œå ã§ããŠããŸãã®ã§æ³šæãå¿ èŠã§ãã
ãéçºè åãã®ãã¯ãèšå®ããšã¯
äžå³ã®ããã¯ãã®èšå®ãã¯äžè¬çã«è¯ãç¥ãããŠãããšã¯æããŸããããã®äžã«é 眮ãããŠãããéçºè åãã®ãã¯ãã®èšå®ãã¯ãéçºè 察象ãªã®ã§è§Šãã¹ãã§ãªãããšèããããŠãããããããŸããã
ããã¢ã€ã«ãã¡ãã¥ã¿ãâããªãã·ã§ã³ããµã€ãããŒâããã©ã¹ãã»ã³ã¿ãŒããµã€ãããŒâããã©ã¹ãã»ã³ã¿ãŒã®èšå®ããã¿ã³âããã¯ãã®èšå®ããµã€ãããŒ
å·Šå³èµ€æ ã®æã®ãã§ãã¯ããã¯ã¹ã¯ããã©ã«ãã§ã¯Offã«ãªã£ãŠããŸãããOnã«ããäºã§ã§ããå 容ããäžèšã®Microsoft 365ãµããŒãã®ããŒãžã«èšèŒãããŠããŸãã
äžèšããŒãžã®äžçªæåŸã®ãšããã§ãéçºè åãã®ãã¯ãèšå®ããæžãããŠããŸãããéèŠãªéšåã ãã次ã«åŒçšããããŸãã
ãã®ã»ãã¥ãªã㣠ãªãã·ã§ã³ã¯ãMicrosoft 365 ããã°ã©ã ãèªååããVBA ç°å¢ãšãªããžã§ã¯ã ã¢ãã«ãæäœããããã«èšè¿°ãããã³ãŒãçšã§ãã æ¢å®ã§ã¯ãã¢ã¯ã»ã¹ãæåŠããŠãèš±å¯ãããŠããªãããã°ã©ã ãæ害ãªèªå·±è€è£œã³ãŒããçµã¿èŸŒãããšãé»æ¢ããŸãã
ãããOnã«ãããšãã³ãŒããçµã¿èŸŒãããšãã€ãŸããã¢ãžã¥ãŒã«ãè¿œå ãããäºãã§ããããã«ãªããŸãã
ãªãäžçªæåŸã«Microsoft Accessã«é¢ããŠã®äžèšã®æ³šææžããèšèŒãããŠããŸãã
泚: Microsoft Access ã«ã¯ã VBA ãããžã§ã¯ã ã¢ãã« ãªããžã§ã¯ã ãªãã·ã§ã³ãžã®ä¿¡é Œã¢ã¯ã»ã¹ æš©ããããŸããã
å®ã¯Accessã¯Modulesãªããžã§ã¯ãèªäœã«AddFromFileã¡ãœããããAddFromStringã¡ãœãããInsertLinesã¡ãœãããèšå®ãããŠããŠãèœåçã«ã³ãŒãã£ã³ã°ãå€æŽã§ããä»æ§ã«ãªã£ãŠããã®ã§ãä¿¡é Œã¢ã¯ã»ã¹æš©ãã¯ååšããŠããªãããã§ãã
ãããããããšãExcelã®VBAã®æ¹ãå®å šæ§ã¯é«ããšèšããã®ã§ãããæ°ãä»ããªããã°ãªããªãã®ã¯ ãéçºè åãã®ãã¯ãèšå®ããã»ãã¥ãªãã£ã®èŠã«ãªã£ãŠãããšããäºã§ãã
ãã®ã¬ãŒãã解æŸããŠããŸã£ããAccessãšåãã»ãã¥ãªãã£ã¬ãã«ã«ãªã£ãŠããŸãç¹ã¯æ³šæãããã¹ãã§ãã
ãéçºè åãã®ãã¯ãèšå®ããOnã«ããæã®ã³ãŒãã£ã³ã°äºäŸ
ãããã«VBAã®ã³ãŒãã£ã³ã°ã«ãã£ãŠããã®ãã§ãã¯ããã¯ã¹ãOnã«ããäºã¯ã§ããŸããã
ããã¯æåã§Onã«ããããæ¹æ³ã¯ãªãã®ã§ãããäŸãã°ãã¬ãžã¹ããªããŒã¿ãååŸããããã«Onã«ããŠãã ãããèŠãããªããæ©èœæäŸäžOnã«ããå¿ èŠãããããšæãããã¡ãã»ãŒãžã衚瀺ããŠèªå°ãããããããŸããã
ãã®ãããªã¡ãã»ãŒãžã衚瀺ãããæã¯ããŸãã¯çã£ãŠããããå¿ èŠãããããã§ãã
å®è¡ããŠããExcelãã¡ã€ã«ãšåããã©ã«ããŒã«çœ®ãããã¢ãžã¥ãŒã«ãè¿œå ãã
ãŸãã¯å®è¡ããŠããExcelãã¡ã€ã«ãšåããã©ã«ããŒã«çœ®ãããŠãã ã¢ãžã¥ãŒã«ãModule2.basããè¿œå ãããµã³ãã« ã³ãŒãã£ã³ã°ã§ãã
â»æšæºã¢ãžã¥ãŒã«Module1ã«äžèšã³ãŒãã£ã³ã°ãã»ããããäºãæ³å®ããŠModule2ã«ããŠããŸãã
Sub threat1() With ThisWorkbook.VBProject.VBComponents .Import ThisWorkbook.Path & "\Module2.bas" End With End Sub
ã¡ãªã¿ã«Module2.basã®äžèº«ã¯äœã§ãè¯ãã®ã§ãããä»åã¯ã€ãã®ããã«ããŠããŸãã
Attribute VB_Name = "Module2" Sub main() MsgBox "Hallow World!" End Sub
ãªãããµãã«ãŒãã³ãthreat1ãã®ãªãã«ãµãã«ãŒãã³ãmainããåŒã³åºããããããšãã³ã³ãã€ã« ãšã©ãŒ SubãŸãã¯Functionãå®çŸ©ãããŠããŸããããã«ãªã£ãŠå®è¡ããäºãã§ããŸããã
åŸã£ãŠè¿œå ããã¢ãžã¥ãŒã«ãå®è¡ããããã«ã¯ããè¿œå ããã®ã¯å¥ã«äœãããã®ãã¯ããå®è¡ããããšããè¡çºãå¿
èŠã«ãªãã¯ãã§ãã
â»ã絶察ã«å¿
èŠã?ããšèšããããšãã䜿çšã®ããœã³ã³ã®äžã«ã©ã®ãããªCOM ã³ã³ããŒãã³ã(ãªããžã§ã¯ã)ãå°å
¥ãããŠããã?ãã¹ãåãã£ãŠããèš³ã§ã¯ãªã®ã§æå®ã¯ã§ããªãèªèã§ãã
VBProject.VBComponentsãšã¯
ãµãã«ãŒãã³ãthreat1ãã®ãªãã«èšè¿°ãããŠãããVBProject.VBComponentsãã®å ã®VBProjedtã¯Visual Basic ãšãã£ã¿ãŒã®ç°å¢ãæ¡åŒµããããã«äœ¿çšã§ãããªããžã§ã¯ã ã¢ãã«ã§Microsoftã®ããã¥ã¡ã³ãã§ã¯ãVisual Basic ã¢ãã€ã³ ã¢ãã«ããšåŒã°ããŠããŸãã
VBComponentsã³ã¬ã¯ã·ã§ã³ã«ã€ããŠã¯Microsoftããã¥ã¡ã³ãã®Visual Basic For Applicationsã®æ¬¡ã®ããŒãžã§èª¬æããããŠããŸãã
ããããããã³ã¬ã¯ã·ã§ã³ã®å ã®1ã€ãšããŠèª¬æãããŠããã®ã§ãã€ã³ããäžèšã«åŒçšããããŸãã
VBComponents ã³ã¬ã¯ã·ã§ã³äœ¿çšããŠããããžã§ã¯ãå ã®ã³ã³ããŒãã³ããžã®ã¢ã¯ã»ã¹ãè¿œå ããŸãã¯åé€ãè¡ããŸãã
ããã§æ³šæããªããã°ãªããªãã®ã¯ãè¿œå ã ãã§ã¯ãªãåé€ãã§ããç¹ã§ãã
ã€ãŸããäžåºŠè¿œå ããåŸã«è¿œå ããäžã®ã¡ã€ã³ã®éšåãåé€ããŠããŸããšããäœãåããã®ã?ããã远跡ã§ããªãäºã«ãªããŸãã
ãè£è¶³ãåç §èšå®ã®ãMicrosoft Visual Basic for Applications Extensibilityã
VBProjedtãªããžã§ã¯ãã䜿çšããããã«åç §èšå®ã§ãMicrosoft Visual Basic for Applications Extensibilityãããã§ãã¯ããå¿ èŠãããã?ãšãããšãã©ããããã§ãã¯ããŠããªããŠãVBProjedtãªããžã§ã¯ãã¯äœ¿çšã§ããããã§ãã
ãªãåç §èšå®ãããªããã°äœ¿çšã§ããªããªãæ©èœããããããããŸããããVBProjedtãªããžã§ã¯ãã䜿çšãã䜿çšããåã«ã¯å¿ èŠããªãããã§ãã
å®è¡ããŠããã¢ãžã¥ãŒã«ã«ã³ãŒãã£ã³ã°ãè¿œå ãã
åã®ç« äºäŸã§ã¯ãå®è¡ããŠããã¢ãžã¥ãŒã«ãšã¯å¥ã«æ°ãã«ã¢ãžã¥ãŒã«ãè¿œå ããŸããããä»åã¯å®è¡ããŠããã¢ãžã¥ãŒã«ã«ãµãã«ãŒãã³ãè¿œå ããã³ãŒãã£ã³ã°äºäŸã«ãªããŸãã
Sub threat2() With ThisWorkbook.VBProject.VBComponents("Module1").CodeModule .AddFromString ThisWorkbook.Sheets("Sheet1").Range("A1").Value End With End Sub
VBComponentsã³ã¬ã¯ã·ã§ã³ã®CodeModuleãªããžã§ã¯ãã¯ãã³ã³ããŒãã³ãã«é¢é£ä»ããããŠããã³ãŒããå€æŽããå Žåã«äœ¿çšããŸãã
ä»åã¯Sheet1ã®A1ã»ã«ã«æžãããŠããå 容ãã³ãŒããšããŠè¿œå ããŠããŸãã
æžãããŠããå 容ã¯äŸãã°å·Šå³ã®ãããªãã®ã§ããµãã«ãŒãã³ãmain2ãã«ãªããŸãã
ãã®ç¶æ ã§ãµãã«ãŒãã³ãthreat2ããå®è¡ãããšäžå³ã®ããã«ã¢ãžã¥ãŒã«ã®å é ã«ã³ãŒãã£ã³ã°ãè¿œå ãããŸãã
è¿œå ããããµãã«ãŒãã³ãmain2ãã¯Callã¹ããŒãã¡ã³ãã«ãªã©ã§å®è¡ããäºãã§ããŸãã
ãªãCodeModuleãªããžã§ã¯ãã«ãåé€ã®ã¡ãœããã¯ååšããã®ã§ãè¿œå ããã¢ãžã¥ãŒã«ã®ã¡ã€ã³éšåãæ¶ãäºã¯å¯èœã§ãã
ããããã®æ¹æ³ã§ã©ãã確èªãã¹ãã?
ãããããéçºè åãã®ãã¯ãèšå®ãã«ãã§ãã¯ãä»ããŠããªããã°åé¡ã¯ç¡ãã¯ããªã®ã§ãããä»ããŠãããšããæã¯æ¬¡ã®ãããªç¹ã«ãªããŸãã
No | æ¹æ³ | 確èªãã¹ããã€ã³ãã»èšå®å€ |
---|---|---|
1 | importã¡ãœãã | äœãimportããããšããŠããã®ã? |
â»å Žåã«ãã£ãŠã¯ãäœããããæã«import察象ãäœããã å¯èœæ§ããããŸãã | ||
2 | AddFromStringã¡ãœãã | äœãã¢ãžã¥ãŒã«ã«è¿œèšããããšããŠããã? |
â»å Žåã«ãã£ãŠã¯ã€ã³ã¿ãŒãããããååŸããäºãããåŸãŸãã |
ãéçºè åãã®ãã¯ãèšå®ããOffã®å Žå
æåŸã«ãéçºè åãã®ãã¯ãèšå®ãã«ãã§ãã¯ãä»ããŠããªãæã®ã¡ãã»ãŒãžãã玹ä»ããããŸãã
å®è¡æãšã©ãŒ’1004’ã衚瀺ãããŠããã®çç±ãšããŠã¯ã’VBProject’ã¡ãœããã¯å€±æããŸãã:’_Workbook’ãªããžã§ã¯ããã«ãªããŸãã
ã
ã
ãthreat2ããå®è¡ããŠãäžèšã¡ãã»ãŒãžã®ããããã°ããã¯ãªãã¯ãããšåœè©²è¡ã«ããŒã¯ãä»ããŸãã
åŸã£ãŠãéçºè åãã®ãã¯ãèšå®ãã«ãã§ãã¯ãä»ããŠããªããã°ãä»åã®ãããªã³ãŒãã£ã³ã°ã¯ãããã¯ãããã¯ãã§ãã
ãªããä»åãæç« ã®åèªæ°ã1äžåã«è¿ã¥ããŠããŠããŸã£ãã®ã§ããã®ç« ã§ä»åã¯çµããã«ããããšæããŸãã
ãä»åã®ãŸãšãããšã次åã®äºåã
ä»åã¯Excel VBAã³ãŒãã£ã³ã°ã§EXEãã³ãŒãã£ã³ã°èªããã¡ã€ã«ãã¯ãŒã¯ã·ãŒããªã©ã®äžã«é ãããŠããã±ãŒã¹ã«ã€ããŠã説æããããŸããã
Excel VBAã段ã ãšæªæã®ããè¡çºã«å¯Ÿãã察çã匷åãããŠããŠããŸãããéå»ãæ¯ãè¿ã£ãŠèŠããšä»åã説æãããããªäºãScriptControlã䜿ã£ãŠæ®éã«å®è¡ã§ããæ代ããããŸããã
EXEãé èœãããŠããã±ãŒã¹ã§ã¯Excelãã¡ã€ã«ãµã€ãºãä»ã«æ¯ã¹ãŠå€§ãããªã£ãŠããã¯ãã§ãã®ã§ããããªã¡ãã£ãšããéåæã«æ°ä»ãããã©ããã§ãªã¹ã¯ãåé¿ããäºãã§ããå Žåãããã¯ãã§ãã
ãªãExcel VBAã®å®å šæ§ã¯é æ ®ãããŠåŒ·åãããŠããŠããèªèã§ãããæ¬æ¥å¿ èŠãªæ©èœã§ã䜿ãæ¹ã«ãã£ãŠã¯è åšãšãªããã®ãååšãããŠããŸãã®ã§ãå®å¿ããäºã¯ã§ããŸããã
ãŸãæè§è¿œå ãããæ©èœãæå¹ã«äœ¿ããªããã°å®ã®æã¡è ãã«ãªã£ãŠããŸããŸãã
次åã¯ãã€ã³ã¿ãŒãããããããŒã¿ãååŸããã±ãŒã¹ãã«ã€ããŠã話ããããŸãã
以äžãæåŸãŸã§ãäžèªããã ãèª ã«ããããšãããããŸããã