Office 2007/2010 Custom Ribbon Export - vsto

I've gone through the tutorials on how to create a custom ribbon with Visual Studio. I see that you can export your Ribbon XML. Is it possible to utilize this ribbon with another document? Do you have to use Visual Studio at that point or is there a way to embed the custom ribbons into another document? (without VSTO)

Ok... After doing more and more digging. I've come up with some answers.
You do NOT need to do a full-blown VSTO (Visual Studio 2008/2010) Office document to modify the Ribbon (Fluent UI). You can create custom XML (which is real easy if you use the Ribbon designer in Visual Studio) and inject it into the Office document. To make it real simple there is a tool out there that does this for you: Custom UI Editor for Microsoft Office.
Also there are great references on this site: http://www.rondebruin.nl/ for instance: http://www.rondebruin.nl/ribbonx20072010.htm

Related

VSTO Sample code For Sensitivity label Ribbon Item OnClick Events in C#

I need to get changes to a sensitivity label done by clicking the Ribbon item in Microsoft Word.
Does anyone have sample code on catching event changes for sensitivity labels in particular for VSTO C#?
We are using ribbon XML and not ribbon designer and extending AddInBase to start up the word application.
I have tried Document events. I have tried Commands.
Any help will be greatly appreciated. I can't find much documentation for VSTO
These are some VBA references.
You can try using the Document.SensitivityLabel property on ThisDocument/ActiveDocument and listen to the SensitivityLabel.LabelChanged event
The answer is a mixture of #cs answer and #Dimitry's answer (I don't have enough reputation points to mark that your comment was very useful). So thank you very much both of you for your assistance
VSTO no longer has support, so visual studio office tools include interop dll v15.0.0 for .net framework version 4.7.2. On our development machine, we have office 365, which from what I read means the latest interop dll will be installed as part of the installation process which has Microsoft word object library v 16.0
Adding Lastest interop to Visual Studio as a com reference
However visual studio still did not update the interop interfaces. What I had to do was change the wrapper property in the csproject from
<WrapperTool>primary</WrapperTool> to <WrapperTool>tlbimp</WrapperTool>
This updated the interfaces and allowed me to get access to the Document.SensitivityLabel object.
So thank you to all that commented it was greatly appreciated.

Office365 Excel access to the Tools -> References menu for RegExp library

This might sound like a simple question but I'm creating a macro in VBA that uses regular expressions. It turns out VBA doesn't inherently support regex and I need to add a reference to 'Microsoft VBScript Regular Expressions 5.5' to gain access to regex functions in Excel.
All my searching online tells me you need to go to Tools -> References menu to add/remove references that can be used in VBA.
The Tools -> References menu in Excel as obtained from Google
For the life of me I can't see where the Tools -> References menu is in my Excel. I've enabled the Developers tab and it's not there.
This is what I see
If it helps, I'm using Excel on Office 365 (which Wikipedia tells me is Office 2016) on a Mac. Please help me find how I can access the References menu in Excel (whether or not it can be accessed via Tools -> Menu or some other way). Thanks.
You need to open the Visual Basic editor. On the ribbon in Excel, select Developer, then Visual Basic. This will open the VBA interface in a separate window. On this new window, you should see the Tools -> References option.
You need to open the Visual Basic (for applications) Editor, or VBE. On the Developers tab, look for "Visual Basic". It should be the left-most item.
Or, you can press Alt-F11.
The VBE is where you'll find the Tools menu, and the References submenu.

Use of Microsoft icons / button images in commercial software

Does anyone know the exact legal terms of use of the Microsoft Office 2010 Icons Gallery (https://www.microsoft.com/en-us/download/details.aspx?id=21103), especially for commerical applications (i.e. add-ins for Microsoft Office programs)? I couldn't find it anywhere.
Are these button images only provided for private, non-commercial use (they can be easily added to custom-built ribbons, after all)?
Thanks for your answer.
The icons can only be used by the common Fluent Ribbon definitions in your solutions:
Use these icons in your Ribbon solutions by specifying the imageMso value for your controls.
For example:
<button id="myButton" label="My save" imageMso="FileSave" />
creates a button with the Save icon.
So you essentially are not redistributing the icons doing so but address the icons already available in the product. So if you for instance build a commercial product using the Fluent Ribbon UI (i.e. RibbonXML) you are allowed to use the identifiers recognized by the Office host applications. Office itself will provide the images that will be displayed in the Ribbon or Context Menus (right click).
Other than that in general you are not allowed to redistribute the Microsoft IP without written confirmation from Microsoft, see the section on Icons:
https://www.microsoft.com/en-us/legal/intellectualproperty/permissions?30648508-ebb3-4af9-81ba-3cc4c26d67b4=True

Is it possible to write Excel VBA Code in Visual Studio

Is there a way to write VBA Code in Visual Studio. If not is there any other alternatives?
The best you can do is bend the office Visual Basic Editor (VBE) tool to your liking. If you stay in it's native environment you get the full power of error detection, Intellisense, live code running, etc.
My tips...
In the VBE go to Tools > Options > Editor tab.
Turn off 'Auto Syntax Check'. You still get code highlighted errors but no annoying popups.
Go to the Editor Format tab and change the Font to Consolas (Western), Size 11.
For code indenting install the awesome, free, Code Manager. It adds some sick keyboard shortcuts.
Make the Edit toolbar easily accessible for code commenting/uncommenting.
Use Rubberduck to add unit testing, source control, code inspections and refactoring functionality.
With those simple changes you end up with a half way decent, useful, and keyboard friendly environment to write your visually appealing code. :-D
VBA code for Excel can only be written inside Excel using the VBA IDE. VBA projects are stored as part of the Excel file and cannot be loaded into Visual Studio.
However, you can write VSTO (Visual Studio Tools for Office) managed add-ins for Excel using Visual Studio. The following MSDN page covers both developing with VBA and VSTO.
Excel for developers
You could also use the interop features of VBA to consume a (COM) object written in Visual Studio from your VBA code.
I've been looking for an answer to this question myself.
Best I've found myself is the option of exporting a Module ect from Excel with the code you've already written (or blank) and load that up in the Visual Studio Environment.
It doesn't offer much, but the highlighted text and auto indenting is nice and makes it much easier to read compared to the standard VBA environment.
Then once you're done just import it back into Excel.
There is a VSCode extension to do this.
It allows you to write code in VSCode and export it to Excel.
This extension is very useful when you develop in VBA.
Here's the link to download the XVBA extension
Edit :
As Peter Macej said in comment, this solution only works for Visual Studio Code not for Visual Studio
You can certainly add and edit a VBA file (.vb) in your Visual Studio solution, but the intellisense will be worthless/screwed up.
This extension for VScode would probably provide a much better experience: https://marketplace.visualstudio.com/items?itemName=spences10.VBA
If your goal is have your VBA code exposed to source control so you can track changes, then it's still worth it to include in your Visual Studio solution, but just store that VBA code in a plain text file and then use the Excel interop to load it into the appropriate module within the excel workbook, e.g.:
xlWorkbook.VBProject.VBComponents["ThisWorkbook"].CodeModule.AddFromFile(#"C:\PathToYour\VBAcode.txt");
And there are other methods to delete/replace code lines, etc....
You can try xlWings package for python and use it with VS Code https://youtu.be/xoO-Fx0fTpM

Visual Studio Macros Editor

Is there a way to change the macro editor from this default one:
It feels like such a downgrade from Visual Studio 2010. Can I configure Office to use that instead?
no there is no way to my knowledge, VS.NET does not support VBA.
what you can do if you are creating a new word or excel file is create a managed office solution, having installed the VSTO 2010 (Visual Studio Tools for Office) you are able to create managed documents which are handled inside VS 2010 and the automation language is not VBA anymore but C# or VB.NET instead.
this is a viable solution for new files, for legacy files either you convert them if they are small or you keep old VBA code and old VBA editor as in your picture.
Mark I wish MS made a tool to convert from the old format to the new one! :(
There are things you can do to improve it:
Tools > Options > Editor :
Uncheck "Auto Syntax Check"
Tools > Options > Edit Format:
Customize the colors and font
Install the VBA Rubberduck:
http://rubberduckvba.com/
The RubberDuck does auto-indent for you. It also helps you with "unit testing, source control, from code inspections, and refactorings"