I am working with Excel 2013. I've written several macros in Personal Workbook modules. I've created custom buttons in the ribbon to run those macros and everything works fine. Next day I run Excel and the custom buttons are gone. I tried this many times and the result is always the same. Strange thing is that custom buttons that I have created more than a year ago are there and are never removed
I have done some research and it seems that Excel does this for security issues. Is there a way to bypass this button deletion?
VBA macros is not designed for customizing the Ribbon UI (aka Fluent UI) in Office applications. For current document you may include a custom ribbon UI into the document. For example, the following articles describe how to do that for Word documents, but the approach is common for Excel and Word documents:
OfficeTalk: Customizing the Word 2007 Fluent Ribbon is as Easy as 1-2-3 (Part 2 of 2)
OfficeTalk: Customizing the Word 2007 Fluent Ribbon is as Easy as 1-2-3 (Part 2 of 2)
If you need to distribute your customizations on multiple machines, I'd suggest developing a COM add-in instead, for example, it can be a VSTO add-in. That's what they were invented for. Moreover, you can create a custom UI customizations as a part of the add-in.
Read more about the Fluent UI in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
If you customized the ribbon using file->options, you can see the .officeui file in the below folder, I think this file is not synchronized in your next login, but you can copy to your local, and when it's missing you can copy that officeui file to the %appdata% directory as mentioned below.
%appdata%/Microsoft/office
I recommend you to customize the ribbon in your workbook using CustomUI editor, so that it will retain the customization inside your workbook and not as the separate file (OFFICEUI).
Related
I would like to create a custom ribbon bar using VBA code. The examples that I have seen use the Application.ActiveProject property. In my Excel O365, ActiveProjects is not recognized. Am I missing a VBA reference?
The ActiveProjects property belongs to Project, not Excel. The Fluent UI is described in-depth in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
One data provider wants to develop an Excel add-in, these are the requirements:
1) it can be installed on desktop. It adds one menu and buttons in Ribbon, and it also provides some specific functions (to get real-time data, like Bloomberg function).
2) the add-in should work in Excel 2007, 2010, 2013 and 2016.
The question is which technology should be used to create this add-in. Here are some of my thoughts:
1) JavaScript API for Excel does not fit, because it does not work for Excel 2007, 2010.
2) VSTO. Does anyone know if VSTO add-ins work for Excel 2013 and 2016?; Is it possible to build one VSTO add-in that works for all Excel 2007, 2010, 2013 and 2016?
3) C API for Excel. It seems that C API for Excel is used to build XLLs. Does anyone know if C API for Excel can build menu and buttons?
Here are some points :
JavaScript API , they are web based addin, so your add-in won't work without internet but it seems that your solution is for a data provider so I assume your clients will have internet. As you said, it didn't work for pre 2013 versions. see here
VSTO, probably the best option but you need to be aware of a major change related to MDI/SDI between Excel 2013 and previous version. Others small tweaks may appear (image idmso, some events..) but VSTO 2007 should be 2016 compatible. VSTO 2016 doesn't exist, the latest release is 2010 (Version 4.0 Runtime). You should test it regularly during development time to check the compatibility.
It is possible to add a menu (a dropdown list) and a toolbar via the Excel C Api (using xlfAddMenu and xlfAddToolbar) but not ribbon controls that require the COM Interface IRibbonExtensibility. So the only way to add controls to the rubbon is via the COM technology (from wich VSTO is based on). The Excel C API didn't change since the 2007 version so it will be fully compatible for all versions. You can find a working example in the Excel C API 2010 SDK (not in the 2013 SDK -this part has been removed), in the file GENERIC.C , see the xlAutoOpen function. Also please note that it is very difficult to find information about it.
From my point of view, you have two possibilities: 1) implement everything via VSTO or 2) to implement your routines via the Excel C API and to interact with it via a VSTO addin that is just used for ribbon controls. I would suggest you the first solution (VSTO), you'll find more documentation about it.
EDIT :
Just realized your question is also about UDF. There are three ways to add UDFs to Excel : via VBA, via a COM automation and via the Excel C API. The best option for UDF is definitively the EXCEL C API but there exist an open source project that "wrap" this API in C#, see Excel DNA.
EDIT 2 :
As an alternative to VSTO, still in Net, there is the NetOffice project on Codeplex that it is worth trying it, they claim that they support all Excel versions. It won't help you regarding the UDFs part but for the GUI it seems to be a good candidate.
I am working with Excel 2010 but I assume the idea is constant accross all of Office 2010.
I am making an Add in to have some VBA Macros that will work with all of my files and would like to make a ribbon that has buttons bound to these macros. I know how to make a ribbon through Excel Options --> Customize Ribbon but I would like to make one that is shown whenever the Add In is active. This is so I can distribute the Add in with an easy way to run the macros.
Is there a way I can do this? Thanks
UPDATE:
I have read into it and with what I have at my disposal here (Office 2010 and notepad) I am going to have to make the ribbon as an XML document and then put that with my xlam file. I am just not sure on the specifics at this point.
I suppose you are developing a VSTO based add-in. If so, you have two ways to go:
VSTO provides a Ribbon designer which you can use to build the custom UI. See Walkthrough: Creating a Custom Tab by Using the Ribbon Designer to get started quickly.
The other way is to use the Ribbon XML markup for buidling a custom UI (available for all kind of add-ins). See Walkthrough: Creating a Custom Tab by Using the Ribbon Designer for more information.
In general, the Fluent UI ( aka Ribbon UI) is described in the following series of articles in MSDN:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
I ended up doing it by hand based on this answer.
Worked well, just a little tricky working with zipping the Excel Files. Never Unzip the entinre file, just open it with explorer and copy files into it and it worked well!
I really need help, sorry if this question has been already asked.
I have a addin installed on my computer for Excel, which creates a new Ribbon Tab, named "Forecast". This tab is useful only for a specific file, and for the other Excels I want it to be hidden.
I've been thinking on this a lot, and I came to the conclusion that the tab has to be hidden by default and shown by VBA code on opening of the file and hidden on beforeClose event, but I don't really know how to do this.
If anyone else has a better idea and would like to help me, I am very thankful.
Thank you
There is no properties which available via the object model. The Ribbon UI is a static thing, to get any dynamism you need to use callbacks defined in the XML markup.
To get the job done you need to use the getVisible attribute for the tab control. When a document is opened/closed you can check out whether the tab should be displayed or not. If required, you can call the Invalidate or InvalidateControl methods of the IRibbonUI interface to force the application to call your callbacks anew. Thus, you can show or hide a tab dynamically.
Read more about the Fluent UI (aka Ribbon UI) in the following series of articles in MSDN:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
What is the best way to have a bookmark of commands for MS office application (mainly excel, project). For example, I need to group some of the most used reports in MS project or buttons to invoke a macro. Something like custom ribbon (with a tab and action buttons) would do, but the problem is it affect all the files. I want to do per file basis.
Ribbon customization in Excel can be done on a per file basis in 2007 and 2010. The excel file container is a .zip file that contains an XML file that details any ribbon customization.
You can get the basics from this msdn article:
Display and Hide Tabs, Groups, and Controls on the Microsoft Office Ribbon
It's written by Ron de Bruin, his website is http://www.rondebruin.nl/tips.htm which has some additional resources for ribbon customization.
For re purposing existing excel commands the structure is fairly simple and should be readily achievable for your purpose.