Skip Navigation Links.
Expand VBAVBA
엑셀프로그래밍이 필요한 이유
Expand ExcelExcel
Expand External LibraryExternal Library
Expand SolutionSolution
Expand EssayEssay

Excel & VBA---Brain Training




아래는 2007 버전과 2003 버전에서 메뉴줄을 다룰때
어떤 차이가 있는지 보기 위한 것들이다
아래를 통합문서의 WorkBook_Open프로시져에 작성하시고

VBA프로그래밍이 자신없는 분은 하지 않는 것이 좋다
뭐가 갑자기 우루르 메뉴에 나타나면 겁이 나서 어쩔줄 몰라하니까..

Private Sub Workbook_Open() Dim oBar As CommandBar Dim oBarButton As CommandBarButton Dim iNext As Integer Set oBar = Application.CommandBars.ActiveMenuBar For iNext = 21 To 99 With oBar.Controls Set oBarButton = _ .Add(Office.MsoControlType.msoControlButton) With oBarButton .Style = msoButtonIconAndCaption .FaceId = iNext .Caption = "UNO_" & iNext .OnAction = "copyPictureOfButton" End With End With Next End Sub

아래를 통합문서의 WorkBook_BeforeClose프로시져에 작성하시면
작성하지 않으면 버튼이 계속화일이 열릴때 마다 만들어지니까..
알아서 하시고..
아무튼 엑셀 망가질까바 겁나는 분은 이 문제는 잊어버리시고..!!!

Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim oBar As Office.CommandBar Dim oBarButton As Office.CommandBarControl Set oBar = Application.CommandBars.ActiveMenuBar For Each oBarButton In oBar.Controls If TypeName(oBarButton) = "CommandBarButton" Then oBarButton.Delete End If Next End Sub

아래 그림과 같이 메뉴에 버튼이 만들어진다



문제는 버튼을 크릭하면 아래의 그림과 같이 버튼의
그림이 시트에 버튼의 만들어진 순서의 갯수대로
시트상에 만들어지게 하는 것!!



위와 같이 만들어 놓은 버튼은 크릭하면 copyPictureOfButton이라는
프로시져가 존재하지 않는 다는 메시지가 뜬다!!
그러니..
copyPictureOfButton이라는 프로시져를 작성하는 문제
2007의 리본이라는 새로운 메뉴시스템상에서
기존의 CommandBar,CommandBarControl이 어떻게 처리되는지
관찰하기 위함이고 버튼의 그림을 복사하여 시트에 어떻게
옮기는지를 관찰하기 위한 문제이다




BrainTraining_060.