Add-in adds button to Home without code? - excel

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.

Related

How to create an add-on and share it with other people?

I have created a few macros with the help of this community the last week, but now I am going to be off work for some time, therefore I need to hand my work over but for that people will need access to my macros. I have created a custom tab for myself that contains all my macros and they only need to follow instructions and click on them in theory.
I however, had issues creating that add-in. I have created the .xlam file but even though people select and load it my macros won't appear, neither at the developer -> Macros tab, nor my tab will appear. The only way for them to run my macros if the add-in is loaded if they go into the visual basic window and run it from there, but I don't want them to do that as I want to protect that with a password eventually.
If somebody has got a solution and willing to help, thanks in advance.
Into the Visual Basic window, you can import your .xlam file with Tools > References > Browse. Now, you should see your file into the Project Explorer of Visual Basic.
Hope this help !
There are couple of different ways you can install an Excel .xlam add-in.
Method One
Save the add-in Excel's start-up folder. Any Excel files saved in this folder are automatically loaded when Excel starts. To view the start-up path:
Open the Visual Basic window.
Open the Immediate Window (Ctrl + G or View >> Immediate Window).
Type ? Application.StartupPath.
You can also change the start-up path:
Click File >> Excel Options >> Advanced.
Under General, in the At Startup, open all files in box, type the full path of the folder that you want to use as the alternate startup folder.
Method Two
You can install the add-in directly:
Click File >> Options >> Add-ins
Pick Excel Add-ins from the manage drop-down (near the bottom of the screen).
Press Go >> Browse...
Navigate to the .xlam add-in you want to use.

Issue With Excel Template Files

I have been using Microsoft Excel 2003 since it first came out and am only just coming across an apparent problem with it. I have a number of .xlt files that are used throughout the company and have never had any issues with them. However, it has just come to light that there is a user who can change the template.
Ordinarily you open the Template file (e.g. Template.xlt) and on opening it find it is called Template1. On pressing the save icon you are taken to the the Save As screen with the default option to save the file as Template1.xls in MyDocuments (Default location).
In this one case though, the user opens the file as Template, and on pressing the save icon overwrites the original .xlt file. I have never seen this before and am bamboozled. Any ideas please?
How exactly does the user open the template?
If a template is opened by double clicking the .xlt (or .xltx/.xltm) file in Windows Explorer, the template generates a new Excel file based on the template.
If an .xlt (or .xltx/.xltm) is right-clicked in Windows Explorer and then the "Open" command is selected in the context menu, then the template file itself will be opened.
If an .xlt (or .xltx/.xltm) template file is opened via Excel's File > Open dialog, the template file itself is opened.
A shortcut that leads to an Excel template behaves in this way:
double-click - creates a new file based on the template.
right-click > New - creates a new file based on the template.
right-click > Open - opens the template itself.
Edit: if the behaviour of double clicking a template file (or a link to a template) occurs only for one user, you may want to unregister and re-register Excel 2003.
Quoting from this question at the Microsoft Answers forum:
> Start>Run>excel /unregserver
> - note the space between excel and /unregserver then
> Start>Run>excel /regserver
> - again note the space between excel and /regserver
I know it's not the best form to answer your own questions, but hopefully someone else will be able to benefit from the solution that I have found.
In order to solve this, download and install a program named FileTypesMan.
Run the program and find the .xlt extension. In an ordinary working system this will have at least New and Open as options with New set to default. In this case there was only Open as an option. Create an option for New and set this to default.....Presto, sorted.

Sharing custom macros and custom Excel Ribbon with others via Sharepoint

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.

Microsoft Open XML unsaved file

Is it possible, through VBA, to get the Open XML definition of the current, unsaved workbook (without saving it)?
Carlos
For playing around with xml files in Excel I've been using the free tool Custom UI Editor for Microsoft Office. I've been using this to customise the ribbon in Excel. The tool looks very simple:
An example of a customization looks like this:
Pretty sure I downloaded the tool from here:
http://openxmldeveloper.org/

What is the best way to package and distribute an Excel application

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.

Resources