My colleagues and I use Excel 2013 and Sharepoint
I have written some custom macros which I have stored in Personal.xlsb
I have also customized the ribbon to add a tab to access these macros.
What is the best way of sharing these macros and the ribbon with my colleagues? (and keeping them updated)
One way is as follows (and this needs to be done each time there is a change)
right-click Ribbon | Customize the Ribbon | Import/Export | Export all Customizations and send this XML file to my colleagues and ask them to import it
Send my colleagues my Personal.xlsb and ask them to overwrite their own with this.
However is there a better way - involving manual effort on the part of my colleagues as little as possible.
I thought perhaps of saving the macros as a sharepoint document, and then editing the XML document to point to this sharepoint document.
The best answer that I have come up with is as follows:
Not to save the files in personal.xlb but to save them in an AddIn (an .xlam file)
To add the menus to the Addin via Custom UI Editor For Microsoft Office (downloadable from http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2009/08/07/7293.aspx)
To save the file in the "Shared With Everyone" folder of "SkyDrive Pro"
To send a link to the file to my colleagues
This seems to solve all the issues. If I do an update then it seems that if my colleagues restart their computer then the addin is updated automatically.
Related
I have surfing the net for months already and haven't really found a solution to the following task I would like to perform. Here is a deal.
I am writing a bunch of code in VBA, which basically creates a new worksheet in a workbook with a specific type of calculators (there are many) for job purposes. One sheet - one type of calculator/analysis.
What I want to accomplish is, that due to increasing amount of code - I would like to put everything on to the ribbon, so I can access a macro through that. However, the job is based on to the case-to-case analysis basis, so the each new project requires a new Excel workbook to be created, where I can choose the calculator I want and do the job.
In addition to that, it requires to be launched on all computers with Excel in the network, with ability for me to be able to modify/add a code to the macro, so that all PC's can stay up-to-date simultaneously.
To wrap-up shortly:
There is a bunch of VBA macros (which I'm constantly updating/adding);
I need to access those macros through the Ribbon in any new workbook (not the one macro are located) on a number of computers in the network;
There is a need to provide instant updates of the code for Ribbon and macro users.
SO, is there any solution, like - I create 2 files (one with Ribbon configuration, another with calculators) and drop them into the server folder? Each user access them once during the installation (basically locating the folder, where the addins are located), and if I need to modify something - I do it with those two files in the server folder and that's it.
If it's not real or pretty hard (for non-programmer) to instantly update all the users, the manual update can work out, but the minimum of being able to access the ribbon in each new workbook is a must.
Thank you in advance for help.
Thanks to all of you folks, who contributed on the question. Want to summarize the experience and provide the way I managed to go with it.
1) Get your VBA code
Let's have a code like this. It can be whatever you feel like. To do so, open VBA in the Developers tab or by pressing Alt+F11. Create a new Module, by right clicking on VBAProject > Insert > Module, name it sayMsg in the Properties window and enter the following code:
Sub saySomething()
MsgBox "What's up?"
End Sub
As I said above - this module can contain anything, usually the functional part of your code, which is going to be called out in another module later.
Let's create a new module the same way we created the first one and name it sayRibbon. This separate module contains a call function or so called "button", which runs our subroutine from sayMsg module. Copy > Paste the code below:
Private Sub sayButtons(Control As IRibbonControl)
Select Case Control.ID
Case Is = "saySomething_Btn"
Call saySomething
Case Else
End Select
End Sub
Basically, what we have here is a Case named saySomething_Btn, which is the "button" itself, with its defined call function.
Now save it as Excel Add-in file .xlam and close the program.
Notice: when you choose .xlam from a drop down menu, you will automatically be located in default Microsoft > AddIns folder. In order to save it on your Desktop, first of all choose the file type, and then relocate the folder.
2) XML map by Office RibbonX Editor
The utility above provides you with the option to create a custom tab in the Excel ribbon. Follow the link for download. All installation and use instructions are also available by that link.
After you finish with an install, open OfficeRibbonXEditor.exe file.
File > Open your .xlam file. Now it appeared in the list below.
Right click > Insert Office 2010+ CustomUI Part (or Insert Office 2007 CustomUI Part - depends on the Office version you are running).
Copy > Paste the code below:
Code
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" xmlns:Q="sayRibbon">
<ribbon startFromScratch="false">
<tabs>
<tab idQ = "Q:rxTabUI" label="Say Something" insertAfterMso="TabView">
<group idQ="Q:rxGrpUI" label="Say">
<button id="saySomething_Btn" label="Say Something" onAction="sayButtons" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Press Validate, in case of issues - the error message will appear (Debug if needed, but you shouldn't in this case).
Now Save and Close the Ribbon Editor. You can only save, when .xlam is not opened by Excel.
3) Access the .xlam Add-In in any WorkBook
The main purpose of such approach was to provide an easy access to the VBA code from any Workbook in Excel and from any machine in the corporate network without actually installing it separately on each individual computer.
It doesn't really matter - do you want to get access only on your PC or local network, the installation process is the same.
Place .xlam file to any location of your choice (local folder or server).
Go to Excel > File > Options > Add-Ins.
Press Go... button below, Browse for the .xlam location and press OK.
Ensure the Add-In is marked in a list. Press OK.
Notice: I would recommend to encrypt your VBA for security reasons, in case if you want to be the one, who actually can edit the code - to eliminate any issues, which may arise if VBA code isn't encrypted.
I have checked the performance on my corporate network, the results are quite satisfying. All the changes you perform in the code are instantly updated among all users after they restart their Excel application.
Don't forget to release the change notes and to keep at least couple of older versions available for people, in case of need or emergency.
As long as the project will evolve, maybe more complex approaches could be used, however due to boundaries I am currently facing, this approach provides the best performance at the moment.
I have downloaded a simple XLAM add-in (I think it's from Microsoft) to remove all non native styles from the active workbook.
This add-in adds a Remove Styles button next to Home/Styles.
However, I looked at the code in the add-in and I can't find any trace of code to add/remove this button.
Can someone explain how to do this magic trick ?
CustomUI elements are xml code that lives in the workbook. There are couple of ways you can see this.
Download the Custom UI Editor for Microsoft Office
Download the Ribbon editor from YourSumBuddy
Change the name of the file to RemoveSytles.zip (all Excel docs are really just compressed file). Open the zip file and navigate to the customUI folder. Open customUI.xml in your favorite text editor.
I have a tool for three way merge on VBA code inside Excel workbooks - let's call it XlMerge.
My Excel workbook resides inside TFS.
I hoped that if I add my tool as a user tool it will remove merging headache.
But now TFS doesn't show me "merge with custom tool" button for my xlsb file (binary workbook).
Is there any solutions to make TFS show this button?
Try looking at the source code setting for the Team Project. Non-text files are considered unmergable by TFS (e.g. a .DLL file), so you may need to make your .xlsb a type of file that's mergeable. Non-mergable files are usually indicated by a lock accompanying an edit check-out automatically.
I produced several custom macros in Windows, modified the XML so that a custom Ribbon Tab was visible in the 2013 version of Windows, and everything was wonderful.
I'm now trying to produce equivalent functionality for Excel 2011 for Mac. I did the following: View >> Toolbars >> Custom Toolbars and Menu. I then went to the "Commands" toolbar >> Macros, and dragged SmileyFace macros to the main toolbar. I then changed the images, modified the text, and it worked locally.
For redundancy, I also added a new menu to "Toolbars and Menu" and added all my macros to that toolbar as well, which appeared as some sort of goofy, nebulous floating box. I attached the macros to the document using the "attach" button.
However, when I send the document to colleagues, the only thing that appears is that nebulous floating custom toolbar, with none of the macros mapped to buttons, and the buttons don't have my custom image.
How do I do this?
The most recent version of Excel 2011 (14.3.5) seems to save custom toolbars in a single file in specific user folder:
Users/[User]/Library/Application Support/Microsoft/Office/Preferences/Office 2011/Microsoft Excel Toolbars.xlsx
(original source here)
When I saved an Excel 2011 workbook with a custom toolbar on one Mac, and transferred it to another, the toolbar did not appear. When I coied the Microsoft Excel Toolbars.xlsx file over (and dropped it in the proper location), the toolbar did appear.
Note: This location may be specific to more recent versions of Office 2011; older versions seem to store them in Users/[User]/Library/Preferences/Microsoft/Office 2011.
Short-term, you may need to distribute the toolbar file along with the spreadsheet, as well as some means (via script and/or manual instruction) of copying it into the expected location.
<pure speculation>
Longer-term, maybe there's a way to override this default behavior and point to a 'local' copy of the toolbars stored in the distributed file itself. Or, maybe you can use the toolbar file as a template for the distributed spreadsheet.
</pure speculation>
I've writen an Excel-based, database reporting tool. Currentely, all the VBA code is associated with a single XLS file. The user generates the report by clicking a button on the toolbar. Unfortunately, unless the user has saved the file under another file name, all the reported data gets wiped-out.
When I have created similar tools in Word, I can put all the code in a template (.dot) file and call it from there. If I put the template file in the Office startup folder, it will launch everytime I start Word. Is there a similar way, to package and distribute my code in Excel? I've tried using Add-ins, but I didn't find a way to call the code from the application window.
Simply move your code into an Excel Addin (XLA) - this gets loaded at startup (assuming it's in the %AppData%\Microsoft\Excel\XLSTART folder) but if it's a addin, not a workbook, then only your macros and defined startup functions will be loaded.
If the functions depend on a spreadsheet itself, then you might want to use a combination of templates and addins.
I'm distributing part of an application like this, we have addins for Word, Excel and Powerpoint (XLA, PPA, DOT) and also Office 2007 'ribbon' versions (DOTM, XLAM and PPAM)
The addin startup code creates toolbar buttons if they're not found, this means in any workbook/document/etc they can simply hit the toolbar button to run our code (we have two action buttons and one button that displays a settings dialog)
Templates aren't really the way to go for VBA code, Addins are definitely the way to go...
So to load the toolbars on startup we're using something like.. (checking to see if toolbar exists though - code will run for each worksheet that is opened, but toolbars are persistent for the user session)
Public Sub Workbook_Open()
' startup code / add toolbar / load saved settings, etc.
End Sub
hope that helps :)
I always use an Add-in(xla)/Template(xlt) combination. Your add-in creates the menu (or other UI entry points) and loads templates as needed. It also write data that you want to persist to a database (Access, SQLServer, text file, or even an xls file).
The first rule is to keep your code separate from your data. Then, if you later have bug fixes or other code changes, you can send a new add-in and all of their templates and databases aren't affected.
You can modify the user's personal.xls file, stored in the excel startup directory (varies between Office versions). If you have lots of users though, that can be fiddly.
An alternative way to get over your problem is to store the macro in a template (.xlt) file. Then when the users opens it they can't save it back over the original file, but have to specify a new filename to save it as. The disadvantage of this method is that you then get multiple copies of your original code all over the place with each saved file. If you modify the original .xlt and someone reruns the old macro in a previously-saved .xls file then things can get out of step.
Have you looked into ClickOnce deploying the Excel file?
What about to save an excel to network folder with read only permissions ? The authentication can be done with integrated windows authentication and you don't need to store connection password to the database in the VBA. Then you only need distribute a link to this location to your users only once. If you will do an update, you only change data in that folder without user notice.