[¼ö°­±â°£] 2010. 11. 1 ~ 2011. 10. 31
½Åû¹®ÀÇ : À¥Å¸ÀÓ±³À°¼¾ÅÍ 02-3477-8300, ¿î¿µ°ü¸® : ¿ÀÇǽºÆ©ÅÍ 070-7098-2554

±³À°°úÁ¤ ³ªÀÇÇнÀ ¿ÀÇǽºÆÁ °Ë»ö ¹«·á°­ÁÂ
Home ·Î±×ÀΠȸ¿ø°¡ÀÔ °í°´¼¾ÅÍ »çÀÌÆ®¸Ê
¿ÀÇǽºÆ©ÅÍ ±â¾÷ASP¼­ºñ½º > ¹«·á°­ÁÂ
¿¢¼¿ 2000 µû¶óÇϱâ
Ȩ·¯´× ¿¢¼¿ 2000°­ÁÂ
À繫 ÇÔ¼ö °­ÁÂ
¿¢¼¿ 2002 »õ·Î¿î ±â´É
Ȳ±â¼º´ÔÀÇ VBA°­ÁÂ
°û½ÂÁÖ´ÔÀÇ VBAÀ̾߱â
Home > ¹«·á°­Á > ¿¢¼¿
¿¢¼¿, °û½ÂÁÖ´ÔÀÇ ¿ÀÆ©°ø±¸ÇÔ Á¦ÀÛÀ¸·Î ¹è¿öº¸´Â VBA À̾߱â, Excel

1. ¸Þ´º ¸¸µé±â-¥±

Âü°í·Î Á÷Á¢ »ç¿ëÀÚÁ¤ÀÇ ¸Þ´º¸¦ »èÁ¦ÇÏ·Á¸é ´ÙÀ½°ú °°ÀÌ ÇÕ´Ï´Ù.
º¸±â(V)-µµ±¸¸ðÀ½(T)-»ç¿ëÀÚÁ¤ÀÇ(C)¸¦ Ŭ¸¯ÇÏ¸é »ç¿ëÀÚÁ¤ÀÇ ´ëÈ­»óÀÚ°¡ ³ª¿É´Ï´Ù. ¿©±â¿¡¼­ ¿ø·¡»óÅ·Î(R)¸¦ Ŭ¸¯ÇÏ¸é µË´Ï´Ù.

 <»ç¿ëÀÚÁ¤ÀÇ ´ëÈ­»óÀÚ>

   With Application.CommandBars("Worksheet Menu Bar")

With ¹®Àº °³Ã¼ÂüÁ¶¸¦ °£·«È÷ ÁÙ¿© »ç¿ëÇϱâ À§ÇÑ °ÍÀÔ´Ï´Ù. ±ä °³Ã¼À̸§À» ¸Å¹ø ¹Ýº¹Çϱ⠺¸´Ù´Â With°ú ÇÔ²² ¼±¾ðÇÏ°í ÀÌÈÄ End WithÀü±îÁö ".(ÂÀ)°³Ã¼ÀÇ ÇÏÀ§¿ä¼Ò"·Î Ç¥ÇöÇÏ´Â °ÍÀÌ ¼ö¿ùÇÕ´Ï´Ù. ¸Å¹ø Application.CommandBars("Worksheet Menu Bar")¸¦ ¹Ýº¹ÇÑ´Ù¸é ¾ó¸¶³ª Áö·çÇÏ°í ¸¹Àº ¿ÀŸ¿Í ¿À·ù°¡ »ý±â°Ú½À´Ï±î?

      bytBefore = .Controls.Count
¿ø·¡´Â Application.CommandBars("Worksheet Menu Bar").Controls.CountÀε¥ With ¹®À» »ç¿ëÇ߱⠶§¹®¿¡ .Controls.Count·Î¸¸ °£·«È÷ Ç¥½ÃÇßÁÒ. ÀÌ°ÍÀº CommandBars("Worksheet Menu Bar") Ä÷º¼Ç¾È¿¡ ÄÁÆ®·Ñ¼ö¸¦ µ¹·ÁÁÝ´Ï´Ù.

 À§ÀÇ ±×¸²À» º¸½Ã¸é 1,2,3¡¦À¸·Î ¸Þ´º¿¡ ¹øÈ£¸¦ ºÙ¿© µÎ¾ú½À´Ï´Ù. µµ¿ò¸»±îÁö ¸ðµÎ 10°³ÀÇ ¸Þ´º°¡ ÀÖÀ¸¹Ç·Î bytBefore ´Â 10ÀÌ µË´Ï´Ù.

      bytRow = 2
Sheet1¿¡¼­ ù¹ø° ÇàÀº Çʵå¸íÀÌ Â÷ÁöÇÏ°í µÎ¹ø° ÇàºÎÅÍ µ¥ÀÌÅÍ°¡ ½ÃÀ۵ǹǷΠbytRow´Â 2·Î ÁöÁ¤ÇÕ´Ï´Ù.

      Do Until IsEmpty(Sheet1.Cells(bytRow, 1))
Do Unitl~Loop¹®À» »ç¿ëÇÏ¿© True°¡ ³ª¿Ã¶§ ±îÁö Áï, µ¥ÀÌÅÍ°¡ ¾øÀ»¶§ ±îÁö ·çÇÁ¸¦ µ¹¸®°í ÀÖ½À´Ï´Ù. IsEmpty()ÇÔ¼ö´Â º¯¼ö°¡ ÃʱâÈ­µÇÁö ¾Ê°Å³ª, Empty·Î ¼³Á¤µÇ¸é True¸¦, ±×·¸Áö ¾ÊÀ¸¸é False¸¦ ¹ÝȯÇÕ´Ï´Ù. ÀÌ°ÍÀº ´ÙÀ½°ú °°ÀÌ °íÃÄ ¾µ ¼ö ÀÖ½À´Ï´Ù
          Do Until Len(Sheet1.Cells(bytRow, 1))=0
Len( )ÇÔ¼ö´Â ¹®ÀÚ¿­ÀÇ ±æÀ̸¦ µ¹·ÁÁÝ´Ï´Ù. µû¶ó¼­ ¹®ÀÚ¿­ÀÇ ±æÀÌ°¡ 0ÀÌ¸é ´õ ÀÌ»ó µ¥ÀÌÅÍ°¡ ¾ø´Â °ÍÀ¸·Î ÆÇ´ÜÇØ¾ß °ÚÁÒ.

        With Sheet1
           usrMnu.mnuLvl = .Cells(bytRow, 1)
           usrMnu.mnuCaption = .Cells(bytRow, 2)
           usrMnu.mnuMacro = .Cells(bytRow, 3)
           usrMnu.mnuDivider = .Cells(bytRow, 4)
           usrMnu.mnuFaceID = .Cells(bytRow, 5)
           usrMnu.mnuState = .Cells(bytRow, 6)
           usrMnu.mnuNextLvl = .Cells(bytRow + 1, 1)
       End With

À§ºÎºÐÀº Sheet1ÀÇ ÀڷḦ Àоî¿Í¼­ ÀÌ¹Ì ¼±¾ðÇÑ »ç¿ëÀÚÁ¤ÀÇ º¯¼öÀÎ usrMnu¿¡ °ªÀ» ÇÒ´çÇÏ´Â ºÎºÐÀÔ´Ï´Ù. ¸¶Áö¸· ºÎºÐ(usrMnu.mnuNextLvl = .Cells(bytRow + 1, 1))À» º¸¸é ¹Ì¸® ´ÙÀ½ÇàÀÇ ¸Þ´º·¹º§À» Àоî¿É´Ï´Ù. ÀÌ°Ô ¿Ö ÇÊ¿äÇÒ±î¿ä? À§ÀÇ <MENU_LEVEL1 Æ˾÷¸Þ´º¹Ù>ÀÇ ±×¸²À» º¸½Ã¸é ¾Ë°ÚÁö¸¸, ´Ý±â(C) °°Àº °æ¿ì ÇÏÀ§¸Þ´º°¡ ¾ø´Â °Í¿¡ ºñÇØ Àμ⿵¿ª(T)ÀÇ °æ¿ì ÇÏÀ§¸Þ´º°¡ ÀÖ½À´Ï´Ù. ÇÏÀ§¸Þ´º°¡ ¾ø´Ù¸é ¹Ù·Î ½ÇÇà¸ÅÅ©·Î¸¦ °É¾î µÎ¾îµµ µÇÁö¸¸ Àμ⿵¿ª(T)ó·³ ÇÏÀ§¸Þ´º°¡ ÀÖ´Ù¸é ÇÏÀ§¸Þ´º¸¦ ¸¸µé°í ³­ µÚ ½ÇÇà¸ÅÅ©·Î¸¦ °É¾î ÁÖ¾î¾ß ÇÕ´Ï´Ù. µû¶ó¼­ ´ÙÀ½ ÇàÀÇ ¸Þ´º·¹º§À» ¹Ì¸® ¾Ë¾ÆµÑ ÇÊ¿ä°¡ ÀÖ½À´Ï´Ù. ÀÌ ºÎºÐÀº ´ÙÀ½¿¡ ¼³¸íÇÏ°Ù½À´Ï´Ù.

    Select Case usrMnu.mnuLvl
¸Þ´º·¹º§¿¡ µû¶ó °³Ã¼¸¦ ´Þ¸® »ç¿ëÇØ¾ß ÇϹǷΠSelect¹®¿¡ usrMnu.mnuLvlÀ» ÆÇ´ÜÇϵµ·Ï Çß½À´Ï´Ù.
    Case MENU_LEVEL0
¿öÅ©½ÃÆ®¸Þ´º¹Ù¿¡ ¿ÀÆ©°ø±¸ÇÔÀ» Ãß°¡ÇÏ´Â ºÎºÐ.


<¿ÀÆ©°ø±¸ÇÔ ¸Þ´º¸¦ ¿öÅ©½ÃÆ®¸Þ´º¹Ù¿¡ Ãß°¡>

    Set cmdbarPopup =
   .Controls.Add(Type:=msoControlPopup,Before:=bytBefore)

Application.CommandBars("Worksheet Menu Bar")°³Ã¼¿¡ ÄÜÆ®·ÑÀ» ŸÀÔ°ú À§Ä¡¸¦ ÁöÁ¤ÇÏ¿© Çϳª Ãß°¡ÇÑµÚ cmdbarPopup °³Ã¼º¯¼ö¿¡ ÇÒ´çÇÕ´Ï´Ù. cmdbarPopup °³Ã¼º¯¼ö´Â ¿ÀÆ©°ø±¸ÇÔÀ» ÀǹÌÇÏ´Â °ÍÀÔ´Ï´Ù.

      With cmdbarPopup
         .Caption = usrMnu.mnuCaption
         .BeginGroup = usrMnu.mnuDivider
         .Tag = USER_TAG
      End With
»ç¿ëÀÚ¸Þ´º¸¦ Ãß°¡ÇÏ¿´´Ù¸é ÀÌÁ¦ À̸§µµ ºÙÀÌ°í ²¿¸®Ç¥µµ ºÙ¿©¾ß°ÚÁÒ. ÀÌ·¯ÇÑ ÀÛ¾÷À» Çϱâ À§ÇØ ¾Õ¿¡¼­ cmdbarPopup °³Ã¼º¯¼ö¿¡ Ãß°¡µÈ ÄÜÆ®·ÑÀ» ÇÒ´çÇÏ´Â °ÍÀÔ´Ï´Ù.
¡Ü Caption¼Ó¼º¿¡´Â ¸Þ´ºÀ̸§À» ´ã°í ÀÖ´Â º¯¼ö usrMnu.mnuCaptionÀ» ÇÒ´çÇÕ´Ï´Ù.
¡Ü BeginGroup ¼Ó¼ºÀº ¸Þ´º¿Í ¸Þ´º°£¿¡ ±¸ºÐÀÚ¸¦ ³Ö¾î ÁÙ°ÍÀΰ¡ ¿©ºÎ¸¦ True/False·Î Á¤ÇÏ´Â °ÍÀ¸·Î usrMnu.mnuDivider°ª¿¡ µû¶ó ±¸ºÐÀÚ°¡ µé¾î °¡°Å³ª ¸»°Å³ª ÇÏ°ÚÁÒ.
¡Ü Tag¼Ó¼ºÀº ±×ÀÚü¸¸À¸·Î´Â Å« Àǹ̴ ¾ø½À´Ï´Ù. ´Ù¸¸ °°Àº ºÎ·ùÀÇ °³Ã¼¿¡¼­ Ưº°ÇÑ Àǹ̸¦ ºÎ¿©Çϱâ À§ÇÑ °ÍÀÔ´Ï´Ù. ¿©±â¿¡¼­ Tag¼Ó¼º¿¡ USER_TAG»ó¼ö¸¦ ÁØ °ÍÀº ³ªÁß¿¡ À̸¦ °¡Áö°í ÆÇ´ÜÇÏ¿© ÀÌ ¸Þ´º¸¦ »èÁ¦Çϱâ À§ÇÑ °ÍÀÔ´Ï´Ù. À̺κÐÀº Sub DeleteUserMenu( ) ÇÁ·Î½ÃÁ®¿¡¼­ »ç¿ëµË´Ï´Ù. ±×¶§ ´Ù½Ã ¼³¸íÇÏÁÒ.

   Case MENU_LEVEL1
µÎ¹ø° ´Ü°èÀÇ ¸Þ´º¸¦ ±¸¼ºÇϱâ À§ÇÑ ºÎºÐÀÔ´Ï´Ù.

      If usrMnu.mnuNextLvl = MENU_LEVEL2 Then
¾Õ¿¡¼­µµ ÀÌ¹Ì usrMnu.mnuNextLvlÀÌ ¿Ö ÇÊ¿äÇÑ °¡ ¼³¸íÇÑ ¹Ù ÀÖ½À´Ï´Ù. À§ÀÇ ÄÚµå´Â ´ÙÀ½ ·¹º§ÀÌ MENU_LEVEL2ÀÎ °æ¿ì Áï ÇÏÀ§¸Þ´º°¡ ÀÖ´Â °æ¿ìÀÔ´Ï´Ù.

        Set cmdbarPup = cmdbarPopup.Controls.Add(Type:=msoControlPopup)
¾Õ¼­¿¡¼­ ¿ÀÆ©°ø±¸ÇÔ¸Þ´º¸¦ ´ëÇ¥(´ë½Å)ÇÏ´Â °³Ã¼´Â ¹«¾ùÀ̾úÁÒ? cmdbarPopupÀÔ´Ï´Ù. ¿©±â¿¡ ¸Þ´ºÄÜÆ®·ÑÀ» Ãß°¡ÇØ¾ß ÇÕ´Ï´Ù. µû¶ó¼­ cmdbarPopup.ControlsÄ÷º¼Ç¿¡ ÄÜÆ®·ÑÀ» Ãß°¡ÇÕ´Ï´Ù. ¾Æ·¡ÀÇ ±×¸²À» Âü°íÇϼ¼¿ä.

<cmdbarPopup°³Ã¼º¯¼ö¿¡ °³Ã¼º¯¼öÇÒ´ç>

       With cmdbarPup
         .Caption = usrMnu.mnuCaption
         If usrMnu.mnuDivider <> 0 Then .BeginGroup = True
       End With

ÇÒ´çÇÑ cmdbarPup°³Ã¼º¯¼ö¿¡ À̸§(Caption)°ú ±¸ºÐÀÚ¸¦ Á¤ÇØÁÝ´Ï´Ù. ¿©±â¼­´Â ÇÏÀ§¸Þ´º°¡ Àֱ⠶§¹®¿¡ ½ÇÇà¸ÅÅ©·Î¸¦ °É¾î µÎÁø ¾ÊÁÒ.

     Else
´ÙÀ½¸Þ´º·¹º§ÀÌ ¸¶Áö¸·´Ü°èÀÎ MENU_LEVEL2°¡ ¾Æ´Ï¶ó¸é ´õ ÀÌ»óÀÇ ÇÏÀ§¸Þ´º°¡ ¾ø´Â °æ¿ìÀÔ´Ï´Ù. µû¶ó¼­ °³Ã¼º¯¼ö¸¦ ´Þ¸® »ç¿ëÇÕ´Ï´Ù. cmdbarPup°³Ã¼º¯¼ö°¡ ¾Æ´Ï¶ó cmdbarBtn°³Ã¼º¯¼ö¿¡ °ªÀ» ÇÒ´çÇÕ´Ï´Ù. µû¶ó¼­ ¹Ù·Î ¾Õ¼­¿Í´Â ´Þ¸® ½ÇÇà¸ÅÅ©·Î¸¦ °É¾îµÎ¾î¾ß ÇÕ´Ï´Ù. ¶Ç FaceID¸¦ µÑ ¼ö ÀÖ½À´Ï´Ù. ±×¿Ü CaptionÀ̳ª BeginGroupµîÀÇ ¼Ó¼º¿¡´Â º°´Ù¸¥ Á¡Àº ¾ø±º¿ä.

         Set cmdbarBtn = cmdbarPopup.Controls.Add(Type:=msoControlButton)
         With cmdbarBtn
            .Caption = usrMnu.mnuCaption
            .OnAction = usrMnu.mnuMacro

 
cmdbarBtn°³Ã¼º¯¼öÀÇ OnAction¿¡´Â ½ÇÇà¸ÅÅ©·Î¸¦ °¡Áö°í ÀÖ´Â usrMnu.mnuMacroº¯¼ö¸¦ ÇÒ´çÇÕ´Ï´Ù.

            If usrMnu.mnuDivider <> 0 Then .BeginGroup = True
            If usrMnu.mnuFaceID <> 0 Then .FaceId = usrMnu.mnuFaceID


À§¿¡¼± FaceID¼Ó¼º¿¡ °ªÀ» ÇÒ´çÇÕ´Ï´Ù. FaceID´Â µµ±¸¸ðÀ½ÀÇ ÀÛÀº ¾ÆÀÌÄܱ׸²ÀÔ´Ï´Ù. ¿©·¯ Á¾·ù°¡ Àִµ¥, À̸¦ È®ÀÎÇغ¼ ¼ö ÀÖ´Â À¯Æ¿¸®Æ¼°¡ ÀÖ½À´Ï´Ù. FACEIDS.XLA¶ó´Â °ÍÀä, Á¦°¡ ¸¸µç °Ç ¾Æ´Ï°í JWalk & Associates(http://www.j-walk.com/ss/)¿¡¼­ ¸¸µç °ÍÀÔ´Ï´Ù.

           If Len(usrMnu.mnuState) <> 0 Then
             Select Case LCase(usrMnu.mnuState)
             Case "msobuttonup"
               .State = msoButtonUp
             Case "msobuttondown"
               .State = msoButtonDown
             Case "msobuttonmixed"
               .State = msoButtonMixed
             End Select
           End If

State¼Ó¼ºÀº ¸í·É Ç¥½ÃÁÙÀÇ ¹öÆ°ÄÁÆ®·ÑÀÇ ¸ð¾çÀ» µÇµ¹¸®°Å³ª ¼³Á¤ÇÕ´Ï´Ù. »ç¿ëÇÒ ¼ö ÀÖ´Â MsoButtonState »ó¼ö¿¡´Â msoButtonUp, msoButtonDown, msoButtonMixed µîÀÌ ÀÖ½À´Ï´Ù.

<State¼Ó¼º>

ÀÌ´Â Åä±Û(Toggle)¸í·ÉÀ» °É¾îµÑ ¶§ »ç¿ëÇÕ´Ï´Ù. °¡·É ¼¿±¸ºÐ¼±À» º¸ÀÌ°Ô Çϰųª ¼û±â°Å³ª ÇÒ ¶§, Çà¿­¸Ó¸®±ÛÀ» º¸À̰ųª ¼û±â´Â °æ¿ì À¯¿ëÇÏ°ÚÁÒ. º¸ÀÌ´Â »óÅ´ msoButtonDownÀ¸·Î Ç¥½ÃÇÏ°í, ¾Èº¸ÀÌ´Â °æ¿ì¿£ msoButtonUpÀ¸·Î State»óŸ¦ Ç¥½ÃÇÕ´Ï´Ù.

           End With
         End If
      Case MENU_LEVEL2

¸¶Áö¸· ÇÏÀ§·¹º§ÀÇ ¸Þ´ºÀÎ °æ¿ìÀÔ´Ï´Ù. ¿©±â¼­ ±»ÀÌ ¸Þ´º¸¦ ¿©±â±îÁö´Â µÎ´Â ÀÌÀ¯´Â µÇµµ·Ï ¸Þ´º±¸¼ºÀ» ´Ü¼øÇÏ°Ô ÇÏ´Â °ÍÀÌ ¸¸µå´Â »ç¶÷À̳ª »ç¿ëÇÏ´Â »ç¶÷ ¸ðµÎ ÆíÇϱ⠶§¹®ÀÔ´Ï´Ù. ¸í·É Çϳª¸¦ »ç¿ëÇϱâ À§ÇØ ¾çÆIJ®Áú ¹þ±âµí ¸Þ´º¼Ó¿¡ ¸Þ´º, ´Ù½Ã ±×¼Ó¿¡ ¸Þ´º,¸Þ´º,¸Þ´º,¡¦ÇÏ¸é ¾ó¸¶³ª ÇÇ°ïÇÏ°Ú½À´Ï±î?

     Set cmdbarBtn = cmdbarPup.Controls.Add(Type:=msoControlButton)
ÀÌÁ¦ ´Ù½Ã cmdbarBtnÀ̶ó´Â °³Ã¼°¡ ³ª¿Ô±º¿ä. ¾Õ¼­ÀÇ ¸¶Âù°¡ÁöÀ̹ǷΠ±ä ¼³¸íÀº »ý·«.

      With cmdbarBtn
         .Caption = usrMnu.mnuCaption
         .OnAction = usrMnu.mnuMacro
         If usrMnu.mnuDivider Then .BeginGroup = True
         If usrMnu.mnuFaceID Then .FaceId = usrMnu.mnuFaceID
         If Len(usrMnu.mnuState) <> 0 Then
           Select Case LCase(usrMnu.mnuState)
           Case "msobuttonup"
             .State = msoButtonUp
           Case "msobuttondown"
             .State = msoButtonDown
           Case "msobuttonmixed"
             .State = msoButtonMixed
           End Select
         End If
      End With
   End Select
   bytRow = bytRow + 1
ÀÌÁ¦ Áٹٲã¾ßÁà!
   Loop

   End With

   Set cmdbarBtn = Nothing
   Set cmdbarPup = Nothing
   Set cmdbarPopup = Nothing
ÀÏ¹Ý º¯¼ö¿Í´Â ´Þ¸® °³Ã¼º¯¼ö´Â Set±¸¹®À¸·Î ¸Þ¸ð¸®¸¦ ÇÒ´çÇßÀ¸¸é ´Ù½Ã NothingÀ» ÇÒ´çÇÏ¿© ¸Þ¸ð¸®¸¦ Ç®¾îÁà¾ß ÇÕ´Ï´Ù. ¹°·Ð ÇÁ·Î½ÃÁ®°¡ Á¾·áµÇ¸é ÀÚµ¿ÀûÀ¸·Î ¸Þ¸ð¸®°¡ ÇØÁ¦µÇÁö¸¸, Áß°£Áß°£ ´õ ÀÌ»ó ÇÊ¿ä°¡ ¾ø´Â °³Ã¼º¯¼ö´Â ÇÁ·Î½ÃÁ® Á¾·áÀüÀÌ¶óµµ ÀÌ·¸°Ô Ç®¾îÁÝ´Ï´Ù.

End Sub
ÀÌÁ¦ ¸Þ´º¸¦ ¸¸µå´Â ÇÁ·Î½ÃÁ®¸¦ Á¾·áÇÕ´Ï´Ù.

ÀÚ ¿©±âºÎÅÍ´Â »ç¿ëÀÚÁ¤ÀÇ ¸Þ´º¸¦ »èÁ¦ÇÕ´Ï´Ù.

Sub DeleteUserMenu( )
   Dim cmdbarPopup As CommandBarPopup

   Set cmdbarPopup = Application.CommandBars("Worksheet Menu Bar") _
       .FindControl(Type:=msoControlPopup, Tag:=USER_TAG)

À§ÀÇ ±¸¹®¿¡¼± ´«¿¡ ÀÍÀº °Ô º¸ÀÌ´Â ±º¿ä. USER_TAG! ¸Â½À´Ï´Ù. Sub CreateUserMenu()¿¡¼­ »ç¿ëÇßÁÒ. FindControl¸Þ¼Òµå´Â ÁöÁ¤ÇÏ´Â Á¶°Ç¿¡ ¸Â´Â CommandBarControl °³Ã¼¸¦ µÇµ¹¸³´Ï´Ù. ¿©±â¼­ ÁöÁ¤ÇÑ Á¶°ÇÀ̶õ Tag¸¦ ÀǹÌÇÕ´Ï´Ù. CommandBars Ä÷º¼Ç¿¡ ãÀ» Á¶°Ç¿¡ ¸Â´Â µÎ °³ ÀÌ»óÀÇ ÄÁÆ®·ÑÀÌ ÀÖÀ» ¶§ ù ¹ø° ÄÁÆ®·ÑÀ» °Ë»ö °á°ú·Î µÇµ¹¸³´Ï´Ù. Á¶°Ç¿¡ ¸Â´Â ÄÁÆ®·ÑÀÌ ¾øÀ¸¸é NothingÀ» µÇµ¹¸³´Ï´Ù.

   If Not cmdbarPopup Is Nothing Then
      cmdbarPopup.Delete
      Set cmdbarPopup = Nothing
   End If

End Sub

¾Õ¼­ÀÇ ¼³¸íó·³ NothingÀΰ¡ ¾Æ´Ñ°¡¸¦ ÆÇ´ÜÇÏ¿© ¿ì¸®°¡ ã´Â °³Ã¼¸¦ È®ÀÎÇÕ´Ï´Ù. ¸¸¾à ã¾ÒÀ¸¸é Delete ¸Þ¼Òµå·Î ¸Þ´º¸¦ »èÁ¦ÇÕ´Ï´Ù. ±×¸®°í ¸Þ¸ð¸®¸¦ Ç®¾îÁÝ´Ï´Ù.
À̸¦ ´Ù¸¥ ¹æ¹ý Á» ¹«½ÄÇÑ ¹æ¹ýÀ¸·Î Çغ¼±î¿ä. Application.CommandBars("Worksheet Menu Bar")ÀÇ ControlsÄ÷º¼ÇÀ» Ž»öÇÏ¿© Tag¸¦ È®ÀÎÇÏ¿© ³»°¡ ã´Â °ÍÀÌ¸é °³Ã¼¸¦ »èÁ¦ÇÏ´Â °ÍÀÔ´Ï´Ù.

Sub FindDeleteCmdBarPopup()
   Dim cmdbarPopup As CommandBarPopup

   For Each cmdbarPopup In Application.CommandBars("Worksheet Menu Bar").Controls
      If cmdbarPopup.Tag = USER_TAG Then
        cmdbarPopup.Delete
        Exit For
      End If
   Next
   Set cmdbarPopup = Nothing
End Sub

¿À´ÃÀº ¿©±â±îÁöÀÔ´Ï´Ù. ±×·³ ´ÙÀ½¿¡¡¦.
¡¡

¸ñÂ÷ | ÀÌÀü | ´ÙÀ½

¡¡

¿ÀÇǽºÆ©ÅÍ ±â¾÷ASP¼­ºñ½º 135-880 ¼­¿ï½Ã °­³²±¸ »ï¼ºµ¿ 157-3 ¿¤ÁöÆ®À©ÅÚ 2Â÷ 1603È£ ¢Ï070-7098-2554
Copyright ¨Ï 1999-2008 Officetutor.com All rights reserved
¡¡