ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[¤À¨É] ¥ÎVBA©I¥svbscript°õ¦æ«ü¥O

[¤À¨É] ¥ÎVBA©I¥svbscript°õ¦æ«ü¥O

¥»©«³Ì«á¥Ñ white5168 ©ó 2012-5-6 23:23 ½s¿è

¬ÛÃöªºµ{¦¡½X¦p¤U
  1. Option Explicit '±j¨îÀɮפ¤ªº©Ò¦³ÅܼƳ£»Ý©ú½T«Å§i
½Æ»s¥N½X
  1. Sub ExcelVBACallVBScript()
  2.     Dim vbscript: Set vbscript = CreateObject("msscriptcontrol.scriptcontrol") 'ª½±µ«Å§i¤@­Ó¨Ï¥Î Microsoft Script control 1.0ªºª«¥ó, ¨Ï¥ÎCreateObject¤è¦¡¥i¥H§K°£¦b "³]©w¤Þ¥Î¶µ¥Ø" ¤Ä¿ïMicrosoft Script control 1.0¶µ¥Ø
  3.     vbscript.Language = "vbscript" '¿ï¾Ü©Ò­n¨Ï¥ÎªºScript»y¨¥,¥i¥H¨Ï¥ÎªºScript,¦pJavaScript, VBScript
  4.     vbscript.AddCode "sub aa(): msgbox ""hello.."":end sub " '¨Ï¥ÎVBA¼g¤@¬qvbscriptªºµ{¦¡½X,¨Ã©R¦W¦¹¬qµ{¦¡½Xªº¨ç¼Æ¦WºÙ¬°aa,aaªº¨ç¼Æ­n°µªº°Ê§@¬O°µÅã¥Ü"hello.."
  5.     vbscript.Run "aa" '¨Ï¥ÎVBA¥h©I¥s­è­è¼g¦nªºvbscript aa()ªº¨ç¼Æ
  6. End Sub
½Æ»s¥N½X
PS:¨­¬°Programmer¸Ó¦bµ{¦¡¤º¥[¤Wµù¸Ñ,¥H¤è«K¥¼¨Ó¦^ÀY½Æ²ß®É¥i¥H§Ö³t¤F¸Ñ,¤]Åý¨ä¥L¤H¥i¥H¶¶§Q¾Ç²ß,½Ð¾i¦¨¨}¦nµ{¦¡¼¶¼g®É¥[µù¸Ñªº²ßºD

        ÀR«ä¦Û¦b : §ïÅܦۤv¬O¦Û±Ï¡A¼vÅT§O¤H¬O±Ï¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD