<¿ÀÆ©°ø±¸ÇÔ ¸Þ´º¸¦ ¿öÅ©½ÃÆ®¸Þ´º¹Ù¿¡ Ãß°¡>
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
¿À´ÃÀº ¿©±â±îÁöÀÔ´Ï´Ù. ±×·³ ´ÙÀ½¿¡¡¦.
¡¡ |