Microsoft Office 2000 ÀÌÈÄ ¹öÀü¿¡¼´Â Office ÀÀ¿ë ÇÁ·Î±×·¥À» Çâ»ó½Ã۰í Á¦¾îÇÏ´Â ÀÀ¿ë ÇÁ·Î±×·¥ Ãß°¡ ±â´ÉÀ» ÀÛ¼ºÇÒ ¼ö ÀÖ´Â »õ·Ó°í ÀϰüµÈ ¼³°è ¾ÆÅ°ÅØÃ³¸¦ Áö¿øÇÕ´Ï´Ù. ÀÌ·¯ÇÑ Ãß°¡ ±â´ÉÀ» COM Ãß°¡ ±â´ÉÀ̶ó°í ÇÕ´Ï´Ù. ÀÌ ¹®¼¿¡¼´Â Visual BasicÀ» »ç¿ëÇÏ¿© COM Ãß°¡ ±â´ÉÀ» ÀÛ¼ºÇÏ´Â ¹æ¹ýÀ» º¸¿© ÁÝ´Ï´Ù.
COM Ãß°¡ ±â´ÉÀº Microsoft Ãß°¡ ±â´É µðÀÚÀÌ³Ê Çü½Ä ¶óÀ̺귯¸®(Msaddndr.dll)¿¡ Á¤ÀÇµÈ ´ë·Î IDTExensibility2 ÀÎÅÍÆäÀ̽º¸¦ ±¸ÇöÇÏ´Â Á¾¼Ó ÇÁ·Î¼¼½º COM ¼¹ö(ActiveX DLL)ÀÔ´Ï´Ù. ¸ðµç COM Ãß°¡ ±â´ÉÀº ÀÌ ÀÎÅÍÆäÀ̽º¿¡¼ »ó¼ÓµÇ¸ç 5°¡Áö ¸Þ¼µå¸¦ ±¸ÇöÇØ¾ß ÇÕ´Ï´Ù.
OnConnection
OnConnection À̺¥Æ®´Â COM Ãß°¡ ±â´ÉÀÌ ¿¬°áµÉ ¶§¸¶´Ù ¹ß»ýÇÕ´Ï´Ù. Ãß°¡ ±â´ÉÀº ½ÃÀÛÇÒ ¶§ ÀÚµ¿À¸·Î ¿¬°áµÇ°Å³ª ÃÖÁ¾ »ç¿ëÀÚ¿¡ ÀÇÇØ ¿¬°áµË´Ï´Ù. OnConnectionÀÌ ¼º°øÀûÀ¸·Î ¹ÝȯµÇ¸é Ãß°¡ ±â´ÉÀÌ ·ÎµåµÈ °ÍÀÔ´Ï´Ù. ¿À·ù°¡ ¹ÝȯµÇ¸é È£½ºÆ® ÀÀ¿ë ÇÁ·Î±×·¥Àº Áï½Ã Ãß°¡ ±â´É¿¡ ´ëÇÑ ÂüÁ¶¸¦ ÇØÁ¦ÇÏ¸ç °³Ã¼´Â ¼Ò¸êµË´Ï´Ù.
OnConnection¿¡´Â ´ÙÀ½ ³× °¡Áö ¸Å°³ º¯¼ö°¡ »ç¿ëµË´Ï´Ù.
- Application - È£½ºÆ® ÀÀ¿ë ÇÁ·Î±×·¥ °³Ã¼¿¡ ´ëÇÑ ÂüÁ¶
- ConnectMode - Ãß°¡ ±â´ÉÀ» ¿¬°áÇÏ´Â ¹æ¹ýÀ» ÁöÁ¤ÇÏ´Â »ó¼ö
- ext_cm_AfterStartup - COM Ãß°¡ ±â´É ´ëÈ »óÀÚ¿¡¼ ÃÖÁ¾ »ç¿ëÀÚ¿¡ ÀÇÇØ ½ÃÀÛ
- ext_cm_CommandLine - ¸í·ÉÁÙ¿¡¼ ¿¬°á (Office ÀÀ¿ë ÇÁ·Î±×·¥À» À§ÇÑ COM Ãß°¡ ±â´ÉÀ» ÀÛ¼ºÇÏ´Â µ¥ Àû¿ëµÇÁö ¾ÊÀ½)
- ext_cm_External - ÀÚµ¿È¸¦ ÅëÇØ ¿ÜºÎ ÀÀ¿ë ÇÁ·Î±×·¥¿¡ ÀÇÇØ ¿¬°á (Office ÀÀ¿ë ÇÁ·Î±×·¥À» À§ÇÑ COM Ãß°¡ ±â´ÉÀ» ÀÛ¼ºÇÏ´Â µ¥ Àû¿ëµÇÁö ¾ÊÀ½)
- ext_cm_Startup - ÀÀ¿ë ÇÁ·Î±×·¥À» ½ÃÀÛÇÒ ¶§ È£½ºÆ®¿¡ ÀÇÇØ ½ÃÀÛ (ÀÌ µ¿ÀÛÀº ·¹Áö½ºÆ®¸®ÀÇ ¼³Á¤¿¡ ÀÇÇØ Á¦¾îµÊ)
- AddInInst - È£½ºÆ® ÀÀ¿ë ÇÁ·Î±×·¥À» À§ÇÑ COMAddIns Ä÷º¼Ç¿¡¼ ÀÌ Ãß°¡ ±â´ÉÀ» ÂüÁ¶ÇÏ´Â COMAddIn °³Ã¼¿¡ ´ëÇÑ ÂüÁ¶
- Custom - »ç¿ëÀÚ Á¤ÀÇ µ¥ÀÌÅ͸¦ ÀúÀåÇÒ ¼ö ÀÖ´Â VariantÀÇ ¹è¿
OnDisconnection
OnDisconnection À̺¥Æ®´Â COM Ãß°¡ ±â´É¿¡ ´ëÇÑ ¿¬°áÀÌ ÇØÁ¦µÉ ¶§¿Í ¸Þ¸ð¸®¿¡¼ ¾ð·ÎµåµÇ±â Á÷Àü¿¡ ¹ß»ýÇÕ´Ï´Ù. Ãß°¡ ±â´ÉÀº ÀÌ À̺¥Æ®¿¡¼ ¸®¼Ò½º¸¦ ºñ¿ì°í È£½ºÆ® ÀÀ¿ë ÇÁ·Î±×·¥¿¡ ´ëÇÑ º¯°æÀ» º¹¿øÇØ¾ß ÇÕ´Ï´Ù.
OnDisconnection¿¡´Â ´ÙÀ½ µÎ °¡Áö ¸Å°³ º¯¼ö°¡ »ç¿ëµË´Ï´Ù.
- RemoveMode - Ãß°¡ ±â´É¿¡ ´ëÇÑ ¿¬°áÀ» ÇØÁ¦ÇÏ´Â ¹æ¹ýÀ» ÁöÁ¤ÇÏ´Â »ó¼ö
- ext_dm_HostShutdown - È£½ºÆ® ÀÀ¿ë ÇÁ·Î±×·¥À» ´ÝÀ» ¶§ ¿¬°á ÇØÁ¦
- ext_dm_UserClosed - ÃÖÁ¾ »ç¿ëÀÚ³ª ÀÚµ¿È ÄÁÆ®·Ñ·¯¿¡ ÀÇÇØ ¿¬°á ÇØÁ¦
- Custom - »ç¿ëÀÚ Á¤ÀÇ µ¥ÀÌÅ͸¦ ÀúÀåÇÒ ¼ö ÀÖ´Â VariantÀÇ ¹è¿
OnAddInsUpdate
OnAddInsUpdate À̺¥Æ®´Â µî·ÏµÈ COM Ãß°¡ ±â´ÉÀ» º¯°æÇÒ ¶§ ¹ß»ýÇÕ´Ï´Ù. Áï, È£½ºÆ® ÀÀ¿ë ÇÁ·Î±×·¥¿¡¼ COM Ãß°¡ ±â´ÉÀ» ¼³Ä¡Çϰųª Á¦°ÅÇÒ ¶§¸¶´Ù ÀÌ À̺¥Æ®°¡ ½ÇÇàµË´Ï´Ù.
OnStartupComplete ¹× OnBeginShutdown
OnStartupComplete¿Í OnBeginShutdown ¸Þ¼µå´Â ¸Þ¸ð¸®¿¡ ÀÀ¿ë ÇÁ·Î±×·¥ÀÌ ·ÎµåµÇ°Å³ª ¾ð·ÎµåµÇ´Â °úÁ¤À̱⠶§¹®¿¡ È£½ºÆ® ÀÀ¿ë ÇÁ·Î±×·¥ÀÌ »ç¿ëÀÚ »óÈ£ ÀÛ¿ëÀ» ÇÇÇØ¾ß ÇÏ´Â »óÅ¿¡ µé¾î°¥ °æ¿ì³ª ÇØ´ç »óÅÂÀÎ °æ¿ì¿¡ È£ÃâµË´Ï´Ù. OnStartupComplete´Â ÀÀ¿ë ÇÁ·Î±×·¥ ½ÃÀÛ Áß¿¡ Ãß°¡ ±â´ÉÀÌ ¿¬°áµÈ °æ¿ì¿¡¸¸ È£ÃâµÇ¸ç OnBeginShutdownÀº ÀÀ¿ë ÇÁ·Î±×·¥ Á¾·á Áß¿¡ Ãß°¡ ±â´ÉÀÌ È£½ºÆ®¿¡ ÀÇÇØ ¿¬°áÀÌ ÇØÁ¦µÈ °æ¿ì¿¡¸¸ È£ÃâµË´Ï´Ù.
È£½ºÆ® ÀÀ¿ë ÇÁ·Î±×·¥ÀÇ »ç¿ëÀÚ ÀÎÅÍÆäÀ̽º´Â ÀÌ·¯ÇÑ À̺¥Æ®°¡ ¹ß»ýÇÒ ¶§ ¿ÏÀüÈ÷ Ȱ¼ºÈµÇ±â ¶§¹®¿¡ À̺¥Æ®°¡ ¹ß»ýÇÏÁö ¾ÊÀ¸¸é OnConnection°ú OnDisconnection¿¡¼ ÀϺΠµ¿ÀÛÀ» ¼öÇàÇÒ ¼ö ¾ø½À´Ï´Ù.
COM Ãß°¡ ±â´É µî·Ï
COM Ãß°¡ ±â´ÉÀº ÀϹÝÀûÀÎ COM µî·Ï ¿Ü¿¡µµ COM Ãß°¡ ±â´ÉÀ» ½ÇÇàÇÏ´Â °¢ Office ÀÀ¿ë ÇÁ·Î±×·¥¿¡ µî·ÏµÇ¾î¾ß ÇÕ´Ï´Ù. ƯÁ¤ ÀÀ¿ë ÇÁ·Î±×·¥¿¡ µî·ÏÇÏ·Á¸é Ãß°¡ ±â´ÉÀº Ű À̸§À¸·Î ProgID¸¦ »ç¿ëÇÏ¿© ´ÙÀ½ À§Ä¡¿¡ ÇÏÀ§ ۸¦ ¸¸µé¾î¾ß ÇÕ´Ï´Ù.
HKEY_CURRENT_USER\Software\Microsoft\Office\<OfficeApp>\Addins\<ProgID>
Ãß°¡ ±â´ÉÀº Ä£¼÷ÇÑ Ç¥½Ã À̸§°ú Àüü ¼³¸í¿¡ ´ëÇÑ °ªÀ» ÀÌ Å° À§Ä¡¿¡ Á¦°øÇÒ ¼ö ÀÖ½À´Ï´Ù. »Ó¸¸ ¾Æ´Ï¶ó Ãß°¡ ±â´ÉÀº "LoadBehavior"¶ó´Â DWORD °ªÀ» »ç¿ëÇÏ¿© ¿øÇÏ´Â ·Îµå µ¿ÀÛÀ» ÁöÁ¤ÇØ¾ß ÇÕ´Ï´Ù. ÀÌ °ªÀº ´ÙÀ½À» Á¶ÇÕÇÏ¿© ±¸¼ºµÇ¸ç È£½ºÆ® ÀÀ¿ë ÇÁ·Î±×·¥¿¡¼ Ãß°¡ ±â´ÉÀ» ·ÎµåÇÏ´Â ¹æ¹ýÀ» °áÁ¤ÇÕ´Ï´Ù.
- 0 = Disconnect - ·ÎµåµÇÁö ¾ÊÀ½
- 1 = Connected - ·ÎµåµÊ
- 2 = Bootload - ÀÀ¿ë ÇÁ·Î±×·¥ ½ÃÀÛ ½Ã ·Îµå
- 8 = DemandLoad - »ç¿ëÀÚ°¡ ¿äûÇÒ ¶§¸¸ ·Îµå
- 16 = ConnectFirstTime - ÇÑ ¹ø¸¸(´ÙÀ½¿¡ ½ÃÀÛÇÒ ¶§) ·Îµå
ÀϹÝÀûÀ¸·Î ÁöÁ¤µÇ´Â °ªÀº 0x03(Connected | Bootload)ÀÔ´Ï´Ù.
IDTExtensibility2¸¦ ±¸ÇöÇÏ´Â Ãß°¡ ±â´ÉÀº "CommandLineSafe"¶ó´Â DWORD °ªÀ» ÁöÁ¤ÇÏ¿©, »ç¿ëÀÚ ÀÎÅÍÆäÀ̽º¸¦ Áö¿øÇÏÁö ¾Ê´Â µ¿ÀÛ¿¡ ´ëÇØ ¾ÈÀüÇÑÁö ¿©ºÎ¸¦ ³ªÅ¸³»¾ß ÇÕ´Ï´Ù. 0x00 °ªÀº False, 0x01 °ªÀº True¸¦ ÀǹÌÇÕ´Ï´Ù.
COM Ãß°¡ ±â´É ÀÛ¼º
¾Æ·¡¿¡¼ ¼³¸íÇÏ´Â ¼¼ °¡Áö ¹æ¹ý Áß Çϳª·Î COM Ãß°¡ ±â´ÉÀ» ÀÛ¼ºÇÒ ¼ö ÀÖ½À´Ï´Ù.
Com Ãß°¡ ±â´É ÅÛÇø´À» »ç¿ëÇÏ¿© COM Ãß°¡ ±â´É ÀÛ¼º
Microsoft Office 2000 Developer³ª Microsoft Office XP Developer ¹× Visual Basic 6.0ÀÌ ¼³Ä¡µÇ¾î ÀÖ´Â °æ¿ì COM Add-in.vbp ÅÛÇø´À» »ç¿ëÇÏ¿© °£´ÜÇÏ°Ô COM Ãß°¡ ±â´ÉÀ» ÀÛ¼ºÇÒ ¼ö ÀÖ½À´Ï´Ù. ÀÌ ÇÁ·ÎÁ§Æ®´Â Office 2000 Developer CDÀÇ ODETools\V9\Samples\OPG\Samples\CH11\VB_COM_AddIn ÇÏÀ§ Æú´õ¿¡ ÀÖ½À´Ï´Ù. ÀÌ Æú´õ¿¡ ÀÖ´Â ÆÄÀÏÀ» Visual Basic 6.0 Template\Projects Æú´õ(ÀϹÝÀûÀ¸·Î C:\Program Files\Microsoft Visual Studio\VB98\Template\Projects)·Î º¹»çÇÕ´Ï´Ù. ÅÛÇø´ ÇÁ·ÎÁ§Æ®¸¦ ÀÌ À§Ä¡·Î º¹»çÇϸé ÅÛÇø´ÀÌ Visual Basic 6.0 »õ ÇÁ·ÎÁ§Æ® ´ëÈ »óÀÚ¿¡ ³ªÅ¸³³´Ï´Ù. ÀÌ ÅÛÇø´ ¹× COM Ãß°¡ ±â´É ¸¸µé±â¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ³»¿ëÀº Microsoft Office 2000 Visual Basic Programmer's GuideÀÇ 11ÀåÀ» ÂüÁ¶ÇϽʽÿÀ.
Visual Basic 6 Ãß°¡ ±â´É µðÀÚÀ̳ʸ¦ »ç¿ëÇÏ¿© COM Ãß°¡ ±â´É ÀÛ¼º
Microsoft Visual Basic 6.0¸¸ ¼³Ä¡µÇ¾î ÀÖ°í IDTExtensibility2¸¦ Á÷Á¢ ±¸ÇöÇÒ Çʿ䰡 ¾øµµ·Ï ·¡ÆÛ¸¦ »ç¿ëÇÏ·Á´Â °æ¿ì VB6 Ãß°¡ ±â´É ±¸Ãà¿¡ »ç¿ëµÇ´Â °Í°ú µ¿ÀÏÇÑ Ãß°¡ ±â´É µðÀÚÀ̳ʸ¦ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. Microsoft Excel 2000 ¶Ç´Â 2002¸¦ À§ÇÑ Ãß°¡ ±â´ÉÀ» ±¸ÃàÇÏ·Á¸é ´ÙÀ½ ´Ü°è¸¦ ¼öÇàÇϽʽÿÀ.
- Microsoft Visual Basic 6.0À» ½ÃÀÛÇϰí ÇÁ·ÎÁ§Æ® Çü½ÄÀ¸·Î Ãß°¡ ±â´ÉÀ» ¼±ÅÃÇÕ´Ï´Ù. ¿©±â¼ µðÀÚÀÌ³Ê Å¬·¡½º¸¦ ÇÁ·ÎÁ§Æ®(Connect)¿Í ¾ç½Ä(frmAddin)¿¡ Ãß°¡ÇØ¾ß ÇÕ´Ï´Ù.
- Connect¿¡ ´ëÇÑ µðÀÚÀÌ³Ê Ã¢À» ¿°í ÀÀ¿ë ÇÁ·Î±×·¥ µå·Ó´Ù¿î ¸ñ·Ï¿¡¼ Microsoft ExcelÀ» ¼±ÅÃÇÕ´Ï´Ù.
- ÃÊ±â ·Îµå µ¿ÀÛ µå·Ó´Ù¿î ¸ñ·Ï¿¡¼ ½ÃÀÛÀ» ¼±ÅÃÇÕ´Ï´Ù.
- ÇÁ·ÎÁ§Æ®¿¡¼ frmAddinÀ» Á¦°ÅÇÕ´Ï´Ù.
- ÇÁ·ÎÁ§Æ® â¿¡¼ Connect Ç׸ñÀ» ¸¶¿ì½º ¿À¸¥ÂÊ ´ÜÃß·Î ´©¸£°í ÄÚµå º¸±â¸¦ ¼±ÅÃÇÕ´Ï´Ù.
- µðÀÚÀÌ³Ê ÄÚµå â¿¡¼ Äڵ带 ¸ðµÎ Á¦°ÅÇÕ´Ï´Ù. ÀÌ ÄÚµå´Â Office Ãß°¡ ±â´ÉÀÌ ¾Æ´Ñ VB Ãß°¡ ±â´É¿¡¼ ÀÛµ¿ÇÕ´Ï´Ù.
- ´ÙÀ½ Äڵ带 µðÀÚÀ̳ʿ¡ Ãß°¡ÇÕ´Ï´Ù.
Option Explicit
Dim oXL As Object
Dim WithEvents MyButton As Office.CommandBarButton
Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
On Error Resume Next
MsgBox "My Addin started in " & Application.Name
Set oXL = Application
Set MyButton = oXL.CommandBars("Standard").Controls.Add(1)
With MyButton
.Caption = "My Custom Button"
.Style = msoButtonCaption
' The following items are optional, but recommended.
' The Tag property lets you quickly find the control
' and helps MSO keep track of it when there is more than
' one application window visible. The property is required
' by some Office applications and should be provided.
.Tag = "My Custom Button"
' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, such that if
' the add-in is not loaded when a user presses the button,
' MSO loads the add-in automatically and then raises
' the Click event for the add-in to handle.
.OnAction = "!<" & AddInInst.ProgId & ">"
.Visible = True
End With
End Sub
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As _
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
On Error Resume Next
MsgBox "My Addin was disconnected by " & _
IIf(RemoveMode = ext_dm_HostShutdown, _
"Excel shutdown.", "end user.")
MyButton.Delete
Set MyButton = Nothing
Set oXL = Nothing
End Sub
Private Sub MyButton_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)
MsgBox "Our CommandBar button was pressed!"
End Sub - ÇÁ·ÎÁ§Æ®¸¦ ÀúÀåÇϰí MyAddin.dllÀ» ¸¸µì´Ï´Ù. µðÀÚÀ̳ʰ¡ »ç¿ëÀÚ¸¦ ´ë½ÅÇØ Ãß°¡ ±â´ÉÀ» µî·ÏÇÕ´Ï´Ù.
- Microsoft ExcelÀ» ¿¸é Ãß°¡ ±â´ÉÀ» ·ÎµåÇÒ ¶§¿Í ¾ð·ÎµåÇÒ ¶§ ¸Þ½ÃÁö »óÀÚ°¡ ³ªÅ¸³³´Ï´Ù. Ãß°¡ ±â´ÉÀ» ¼±ÅÃÇϸé Ç¥ÁØ µµ±¸ ¸ðÀ½¿¡ My Custom ButtonÀ̶ó´Â »õ ´ÜÃß°¡ ³ªÅ¸³³´Ï´Ù.
Implements¸¦ »ç¿ëÇÏ¿© COM Ãß°¡ ±â´É ÀÛ¼º
°£´ÜÇÏÁö´Â ¾ÊÁö¸¸ Microsoft Visual Basic 5.0°ú
Implements Ű¿öµå¸¦ »ç¿ëÇÏ¿© IDTExtensibility2 ÀÎÅÍÆäÀ̽º¸¦ Á÷Á¢ ±¸ÇöÇÏ´Â COM Ãß°¡ ±â´ÉÀ» ¸¸µé ¼ö ÀÖ½À´Ï´Ù. ÀÌ ¹æ¹ýÀÇ À¯ÀÏÇÑ ´ÜÁ¡Àº µî·ÏÀÔ´Ï´Ù. Microsoft Visual BasicÀº Office¿¡¼ Ãß°¡ ±â´ÉÀ» µî·ÏÇÏ´Â µ¥ ÇÊ¿äÇÑ Å°¸¦ Ãß°¡ÇÏÁö ¸øÇϱ⠶§¹®¿¡ »ç¿ëÀÚ°¡ º°µµ(»ç¿ëÀÚ ÁöÁ¤ ¼³Ä¡ À¯Æ¿¸®Æ¼ ¶Ç´Â REG ½ºÅ©¸³Æ® »ç¿ë)·Î ¼öÇàÇØ¾ß ÇÕ´Ï´Ù.
Implements¸¦ »ç¿ëÇÏ´Â ÀåÁ¡Àº µðÀÚÀ̳ʸ¦ »ç¿ëÇÏ´Â °Íº¸´Ù ´õ Á÷Á¢ÀûÀ̰í È¿À²ÀûÀ̸ç ÀÛ¾÷ÇÏ·Á´Â °¢ ÀÀ¿ë ÇÁ·Î±×·¥¿¡ ´ëÇØ º°µµÀÇ Connect °³Ã¼¸¦ ¸¸µå´Â ´ë½Å ¿©·¯ Office ÀÀ¿ë ÇÁ·Î±×·¥¿¡¼ ÀÛµ¿ÇÒ ¼ö ÀÖ´Â ´ÜÀÏ COM °³Ã¼¸¦ ¸¸µé ¼ö ÀÖ´Ù´Â Á¡ÀÔ´Ï´Ù.
Implements¸¦ »ç¿ëÇÏ¿© Ãß°¡ ±â´ÉÀ» ÀÛ¼ºÇÏ´Â ´Ü°è´Â ´ÙÀ½°ú °°½À´Ï´Ù.
- Visual BasicÀ» ¿°í ActiveX DLL ÇÁ·ÎÁ§Æ®¸¦ »õ·Î ¸¸µì´Ï´Ù. ÇÁ·ÎÁ§Æ® À̸§À» MyCOMAddinÀ¸·Î ÁöÁ¤ÇÏ°í °ø¿ë Ŭ·¡½º À̸§À» Connect·Î ÁöÁ¤ÇÕ´Ï´Ù.
- ÂüÁ¶ ´ëÈ »óÀÚ(ÇÁ·ÎÁ§Æ® | ÂüÁ¶)¿¡¼ Microsoft Office 9.0(¶Ç´Â Office XPÀÇ °æ¿ì 10.0) °³Ã¼ ¶óÀ̺귯¸®¿Í Microsoft Ãß°¡ ±â´É µðÀÚÀÌ³Ê Çü½Ä ¶óÀ̺귯¸®¿¡ ÂüÁ¶¸¦ Ãß°¡ÇÕ´Ï´Ù. ÂüÁ¶ ¸ñ·Ï¿¡¼ Ãß°¡ ±â´É µðÀÚÀ̳ʸ¦ ãÀ» ¼ö ¾ø´Â °æ¿ì "C:\Program Files\Common Files\Designer" Æú´õ¿¡¼ Msaddndr.dll ¶Ç´Â Msaddndr.tlb¸¦ ã¾Æ¾ß ÇÕ´Ï´Ù.
- ConnectÀÇ ÄÚµå â¿¡ ´ÙÀ½À» Ãß°¡ÇÕ´Ï´Ù.
Option Explicit
Implements IDTExtensibility2
Dim oHostApp As Object
Dim WithEvents MyButton As Office.CommandBarButton
Private Sub IDTExtensibility2_OnConnection(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
On Error Resume Next
' Set a reference to the host application...
Set oHostApp = Application
' If you aren't in startup, then manually call OnStartupComplete...
If (ConnectMode <> ext_cm_Startup) Then _
Call IDTExtensibility2_OnStartupComplete(custom)
End Sub
Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)
Dim oCommandBars As Office.CommandBars
Dim oStandardBar As Office.CommandBar
On Error Resume Next
' Set up a custom button on the "Standard" commandbar...
Set oCommandBars = oHostApp.CommandBars
If oCommandBars Is Nothing Then
' Outlook has the CommandBars collection on the Explorer object
Set oCommandBars = oHostApp.ActiveExplorer.CommandBars
End If
Set oStandardBar = oCommandBars.Item("Standard")
If oStandardBar Is Nothing Then
' Access names it's main toolbar Database
Set oStandardBar = oCommandBars.Item("Database")
End If
' In case the button was not deleted, use the exiting one...
Set MyButton = oStandardBar.Controls.Item("My Custom Button")
If MyButton Is Nothing Then
Set MyButton = oStandardBar.Controls.Add(1)
With MyButton
.Caption = "My Custom Button"
.Style = msoButtonCaption
' The following items are optional, but recommended.
' The Tag property lets you quickly find the control
' and helps MSO keep track of it when there is more than
' one application window visible. The property is required
' by some Office applications and should be provided.
.Tag = "My Custom Button"
' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, such that if
' the add-in is not loaded when a user presses the button,
' MSO loads the add-in automatically and then raises
' the Click event for the add-in to handle.
.OnAction = "!<MyCOMAddin.Connect>"
.Visible = True
End With
End If
' Display a simple message to know which application you started in...
MsgBox "Started in " & oHostApp.Name & "."
Set oStandardBar = Nothing
Set oCommandBars = Nothing
End Sub
Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode As _
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
On Error Resume Next
If RemoveMode <> ext_dm_HostShutdown Then _
Call IDTExtensibility2_OnBeginShutdown(custom)
Set oHostApp = Nothing
End Sub
Private Sub IDTExtensibility2_OnBeginShutdown(custom() As Variant)
On Error Resume Next
' Notify the user you are shutting down, and delete the button...
MsgBox "Our custom Add-In is unloading."
MyButton.Delete
Set MyButton = Nothing
End Sub
Private Sub MyButton_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
MsgBox "Our CommandBar button was pressed!"
End Sub
Private Sub IDTExtensibility2_OnAddInsUpdate(custom() As Variant)
'You do nothing if this is called, but you need to
'add a comment so Visual Basic properly implements the function...
End Sub - ÇÁ·ÎÁ§Æ®¸¦ ÀúÀåÇϰí MyCOMAddin.dllÀ» ¸¸µì´Ï´Ù. ±×·¯³ª Ãß°¡ ±â´ÉÀÌ ÀÛµ¿ÇÏ·Á¸é ½ÇÇàÇÒ °¢ Office ÀÀ¿ë ÇÁ·Î±×·¥¿¡ ¿¬°áÇØ¾ß ÇÕ´Ï´Ù. ½ÇÁ¦ DLLÀ» ¼³Ä¡ÇÏ¸é ¼³Ä¡ À¯Æ¿¸®Æ¼°¡ ÀÌ ÀÛ¾÷À» ¼öÇàÇÒ ¼ö ÀÖ½À´Ï´Ù. ÀÌ ¿¹¿¡¼´Â Visual Basic IDE¿¡¼ Á÷Á¢ µî·Ï ÇÔ¼ö¸¦ È£ÃâÇÕ´Ï´Ù.
- »õ ¸ðµâÀ» ÇÁ·ÎÁ§Æ®¿¡ Ãß°¡ÇÕ´Ï´Ù. Module1ÀÇ Äڵ忡 ´ÙÀ½À» Ãß°¡ÇÕ´Ï´Ù.
Option Explicit
Private Declare Function RegCreateKeyEx Lib "advapi32.dll" _
Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As _
Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, _
phkResult As Long, lpdwDisposition As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" _
Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As _
String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, _
ByVal cbData As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" _
Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) _
As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal hKey As Long) As Long
Private Const HKEY_CURRENT_USER = &H80000001
Private Const KEY_ALL_ACCESS = &H1F0037
Private Const REG_CREATED_NEW_KEY = &H1
Private Const REG_SZ = 1
Private Const REG_DWORD = 4
'These are the settings for your Add-in...
Private Const PROGID As String = "MyCOMAddin.Connect"
Private Const DESCRIPTION As String = "My VB5/6 COM Add-In Sample"
Private Const LOADBEHAVIOR As Long = 3
Private Const SAFEFORCOMMANDLINE As Long = 0
Public Sub RegisterAll()
RegisterOfficeAddin "Access"
RegisterOfficeAddin "Excel"
RegisterOfficeAddin "FrontPage"
RegisterOfficeAddin "Outlook"
RegisterOfficeAddin "PowerPoint"
RegisterOfficeAddin "Word"
End Sub
Public Sub UnregisterAll()
UnRegisterOfficeAddin "Access"
UnRegisterOfficeAddin "Excel"
UnRegisterOfficeAddin "FrontPage"
UnRegisterOfficeAddin "Outlook"
UnRegisterOfficeAddin "PowerPoint"
UnRegisterOfficeAddin "Word"
End Sub
Public Sub RegisterOfficeAddin(sTargetApp As String)
Dim sRegKey As String
Dim nRet As Long, dwTmp As Long
Dim hKey As Long
sRegKey = "Software\Microsoft\Office\" & sTargetApp _
& "\Addins\" & PROGID
nRet = RegCreateKeyEx(HKEY_CURRENT_USER, sRegKey, 0, _
vbNullString, 0, KEY_ALL_ACCESS, 0, hKey, dwTmp)
If nRet = 0 Then
If dwTmp = REG_CREATED_NEW_KEY Then
Call RegSetValueEx(hKey, "FriendlyName", 0, _
REG_SZ, ByVal PROGID, Len(PROGID))
Call RegSetValueEx(hKey, "Description", 0, _
REG_SZ, ByVal DESCRIPTION, Len(DESCRIPTION))
Call RegSetValueEx(hKey, "LoadBehavior", 0, _
REG_DWORD, LOADBEHAVIOR, 4)
Call RegSetValueEx(hKey, "CommandLineSafe", 0, _
REG_DWORD, SAFEFORCOMMANDLINE, 4)
End If
Call RegCloseKey(hKey)
End If
End Sub
Public Sub UnRegisterOfficeAddin(sTargetApp As String)
Dim sRegKey As String
sRegKey = "Software\Microsoft\Office\" & sTargetApp _
& "\Addins\" & PROGID
Call RegDeleteKey(HKEY_CURRENT_USER, sRegKey)
End Sub - Á÷Á¢ ½ÇÇà â(º¸±â | Á÷Á¢ ½ÇÇà â)¿¡ RegisterAllÀ» ÀÔ·ÂÇÑ ´ÙÀ½ Enter ۸¦ ´©¸¨´Ï´Ù. Áö¿øµÇ´Â ¸ðµç Office ÀÀ¿ë ÇÁ·Î±×·¥(Access, Excel, FrontPage, Outlook, PowerPoint ¹× Word)¿¡ µî·ÏµË´Ï´Ù.
- ¾Õ¿¡ ³ª¿µÈ Office ÀÀ¿ë ÇÁ·Î±×·¥À» ¿±´Ï´Ù. ½ÃÀÛ°ú Á¾·á ½Ã ¸Þ½ÃÁö »óÀÚ¿Í Ç¥ÁØ µµ±¸ ¸ðÀ½¿¡ Ãß°¡µÈ »ç¿ëÀÚ ÁöÁ¤ ´ÜÃß°¡ ³ªÅ¸³³´Ï´Ù.
- Ãß°¡ ±â´É µî·ÏÀ» Ãë¼ÒÇÏ·Á¸é Visual Basic Á÷Á¢ ½ÇÇà â¿¡¼ UnregisterAllÀ» ÀÔ·ÂÇÑ ´ÙÀ½ Enter ۸¦ ´©¸¨´Ï´Ù.
"Microsoft Office 2000 Visual Basic Programmer's Guide"ÀÇ 11Àå. Ãß°¡ ±â´É, ÅÛÇø´, ¸¶¹ý»ç ¹× ¶óÀ̺귯¸®
COM Ãß°¡ ±â´É ÀÛ¼º¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ³»¿ëÀº Microsoft ±â¼ú ÀÚ·áÀÇ ´ÙÀ½ ¹®¼¸¦ ÂüÁ¶ÇϽʽÿÀ.
230689
(http://support.microsoft.com/kb/230689/
)
SAMPLE: Visual C++·Î ÀÛ¼ºµÈ Comaddin.exeÀÇ Office 2000 COM Ãß°¡ ±â´É
190253
(http://support.microsoft.com/kb/190253/
)
INFO: VB6 µðÀÚÀ̳ʴ VB5¿¡¼ ÀÛµ¿ÇÏÁö ¾Ê´Â´Ù
Microsoft Internet ExplorerÀÇ À¥ ±â¹Ý ¼Ö·ç¼Ç °³¹ß¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ³»¿ëÀº ´ÙÀ½ Microsoft À¥ »çÀÌÆ®¸¦ ÂüÁ¶ÇϽʽÿÀ.
Âü°í ÀÌ ¹®¼¿¡ ¼³¸íµÈ ´Ü°è³ª À¯»çÇÑ ¹æ¹ýÀ» »ç¿ëÇÏ¿© Visual Basic COM Ãß°¡ ±â´É¿¡¼ Office Word¿¡ ¸Þ´º Ç׸ñÀ» Ãß°¡ÇÏ¸é ¸Þ´º Ç׸ñÀÌ Á¦´ë·Î ÀÛµ¿ÇÏÁö ¾Ê½À´Ï´Ù.
ÀÚ¼¼ÇÑ ³»¿ëÀº Microsoft ±â¼ú ÀÚ·áÀÇ ´ÙÀ½ ¹®¼¸¦ ÂüÁ¶ÇϽʽÿÀ.
313948
(http://support.microsoft.com/kb/313948/
)
WD2002:
Word¿¡¼ COM °³Ã¼ ¸Þ´º Ç׸ñ(CommandBarControl)¿¡ ´ëÇÑ ÂüÁ¶°¡ ¼Õ½ÇµÈ´Ù
?
Microsoft Á¦Ç° °ü·Ã ±â¼ú Àü¹®°¡µé°ú ¿Â¶óÀÎÀ¸·Î Á¤º¸¸¦ ±³È¯ÇϽ÷Á¸é Microsoft ´º½º ±×·ì
(http://support.microsoft.com/newsgroups/default.aspx)
¿¡ Âü¿©ÇϽñ⠹ٶø´Ï´Ù.±â¼ú ÀÚ·á: 238228 - ¸¶Áö¸· °ËÅä: 2005³â 10¿ù 19ÀÏ ¼ö¿äÀÏ - ¼öÁ¤: 6.0
º» ¹®¼ÀÇ Á¤º¸´Â ´ÙÀ½ÀÇ Á¦Ç°¿¡ Àû¿ëµË´Ï´Ù.
- Microsoft Excel 2000 Standard Edition
- Microsoft Office XP Developer Edition
- Microsoft Office 2000 Developer Edition
- Microsoft Access 2002 Standard Edition
- Microsoft Access 2000 Standard Edition
- Microsoft Excel 2002 Standard Edition
- Microsoft FrontPage 2002 Standard Edition
- Microsoft FrontPage 2000 Standard Edition
- Microsoft Outlook 2002 Standard Edition
- Microsoft Outlook 2000 Standard Edition
- Microsoft PowerPoint 2002 Standard Edition
- Microsoft PowerPoint 2000 Standard Edition
- Microsoft Word 2002 Standard Edition
- Microsoft Word 2000 Standard Edition
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
| kbhowto kbautomation KB238228 |