02. april 2007 - 11:54Der er
5 kommentarer og 1 løsning
Brugerdefineret værktøjslinie i Excel 2007 ?
Hej
Jeg har en hel stribe makroer som jeg har tilknyttet til en værktøjslinie i Excel 2003. Nu har jeg fået 2007 og vil gerne lave min egen brugerdefinerede værktøjslinie (ikke den der hurtig start). Er der nogen af jer der har luret, hvordan man gør det i Excel 2007 ? Jeg kan sgu ikke rigtigt finde noget, hverken i Hjælp eller hos Microsoft.
Nu bruger jeg "kun" 2003, men hvis systemet med værktøjslinier ikke er lavet helt om, kan du flytte dine knapper sammen med makroarket.
Hvis du stadig har en computer med Excel og dine knapper osv. intakt kan du gemme en værktøjslinie inden i "person.xls" (eller hvad det nu er for et makroark det drejer sig om): Aktiver knapredigeringen - vælg fanen "værktøjslinier" - tryk på "vedhæft" - marker & kopier de ønskede værktøjslinier - gem "person.xls". Nu er værktøjslinien en del af arket.
Når du har styr på hvor den ny "person.xls" befinder sig, overskriver du med den gamle med værktøjslinien indeni.
Ja, jeg kender xlb'en, og den har fordelen af at indeholde den komplette knapopsætning, mens det kun er muligt at vedhæfte brugerdefinerede værktøjslinier (men de kan jo så bl.a. bestå af de standardknapper man selv synes mangler i startopsætningen...)
Værktøjslinier, der har været vedhæftet forbliver i Excel og er tilgængelige næste gang Excel startes. De skal aktivt slettes for helt at forsvinde igen.
Jeg har fundet ud af at man kan kode et tilføjelsesprogram (xla) der indeholder både værktøjslinie og makroer - Når jeg får 5 minutter lægger jeg lige koden herud.
First, you'll create a new workbook, to store the code that builds the toolbar.
Create a new workbook. Press Alt + F11, to open the Visual Basic Editor (VBE), where macros and user defined functions are stored. In the VBE, press Ctrl + R, to open the Project Explorer Find your new workbook in the list. For example, if your workbook is Book3, it will appear as VBAProject (Book3), as shown at right. Right-click on your workbook name in the list, and choose Insert | Module In the code window that appears on the right hand side, paste all the code that's shown below. In the code, replace aaa and bbb with the names of your macros, and add more items to the list, if you have several macros you want on the toolbar. In the code, replace AAA Caption and BBB Caption with the labels that you want to appear on the toolbar. In the code, replace AAA Tip and BBB Tip with the tooltips that you want to appear when you point to a toolbar button.
Add the Toolbar Code
Option Explicit
Public Const ToolBarName As String = "MyToolbarName" '=========================================== Sub Auto_Open() Call CreateMenubar End Sub
'=========================================== Sub Auto_Close() Call RemoveMenubar End Sub
'=========================================== Sub RemoveMenubar() On Error Resume Next Application.CommandBars(ToolBarName).Delete On Error GoTo 0 End Sub
'=========================================== Sub CreateMenubar()
Dim iCtr As Long
Dim MacNames As Variant Dim CapNamess As Variant Dim TipText As Variant
For iCtr = LBound(MacNames) To UBound(MacNames) With .Controls.Add(Type:=msoControlButton) .OnAction = "'" & ThisWorkbook.Name & "'!" & MacNames(iCtr) .Caption = CapNamess(iCtr) .Style = msoButtonIconAndCaption .FaceId = 71 + iCtr .TooltipText = TipText(iCtr) End With Next iCtr End With End Sub
'=========================================== Sub AAA() MsgBox "aaa" End Sub
'=========================================== Sub BBB() MsgBox "bbb" End Sub
Save the File as an Add-In
First, you'll save the workbook as an Add-In, and make it accessible from other workbooks, as you work in Excel.
In the VBE, choose File | Close and Return to Microsoft Excel. From the Excel menu bar, choose File | Save As. Type a name for the file, e.g. MyMacrosTB From the Save as type dropdown, choose Microsoft Office Excel Add-In (*.xla), at the bottom of the list. Your AddIns directory will automatically be selected, e.g. C:\Documents and Settings\Contextures\Application Data\Microsoft\AddIns. Click the Save button, to save the file. Close Excel.
Install and Use the Add-In
Next, install the Add-In, so you can use it in any workbook.
Open Excel. From the Excel menu bar, choose Tools | Add-Ins. Find your Add-In in the list, and add a check mark to its name. Click OK to close the Add-Ins dialog box. The MyToolbarName toolbar should appear, floating over the worksheet. You can drag it to another position, if you prefer. Click on a button to run that macro.
Ja, det virker jo fint, omend lidt besværligt at vælge ikon %)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.