Building/deploying a simple Word addin - .net-4.0

I am trying to build a simple addin for Word 2007 using Visual Studio 2010 and .NET 4.0. It's a relatively simple addin, which brings up a save dialog and saves the document as a Word 2003 document.
The addin runs fine in Word under Debug mode, but does not run under Release or when I create a setup project for it. (It does create the registry keys under HKCU\Software\Microsoft\Office\Word\Addins and they look to be correct) I don't get any errors, and the addin isn't listed under the Disabled Addins either.
I tried adding the Addin manually but it says that it isn't a valid addin. The version of Office is 32-bit, running under Windows 7 64-bit.
Or are there even any alternatives to using VSTO (VBA?) that will let me add a tab to the Ribbon?

You can use IRibbonExtensibility interface (http://msdn.microsoft.com/en-us/library/microsoft.office.core.iribbonextensibility.aspx) to avoid using VSTO.

Related

How to debug a Word OfficeJs command-only add-in

I am trying to write my first JavaScript Word add-in using Visual Studio Code. As a basis I used the Simple Word Add-in example provided by Microsoft. The example puts all JavaScript code in the commands.html file. I would like to put my code in the separate commands.js file, and use the Word Javascript API instead of the Common API. But with most changes Word just does not respond and I can't see what's happening at this stage.
I have installed the Microsoft Office Add-in Debugger Extension for Visual Studio Code. All examples that I have seen are task pane add-ins, and I was able to attach a debugger to those examples. Is there any way to debug a command add-in (without a task pane)?
Unfortunately the Microsoft Office Add-in Debugger Extension for Visual Studio Code will not work for debugging commands. In order to debug commands, your best bet is to upload your add-in manifest to Office Online, view it in Edge or Chrome and use the DevTools (F12). You should be able to add the add-in project source in the DevTools and just set breakpoints in the commands.
If you are running the Edge Chromium (which I don't think you are based on the fact that Microsoft Office Add-in Debugger Extension worked for taskpane add-ins), debugging commands can all be done in VS Code.

Word Addin application not displayed in the Word ribbon

I made a Word add in application in VS 2010 in C# and it was working fine until I installed the app using Advanced Installer in my development PC and its doesn't display anymore in the Word ribbon. I check the registry files and it looks fine, tried to add the same registry keys in the HKEY_CURRENT_USER and the HKEY_LOCAL_MACHINE directories in the registry Editor window but still no effect.
I even create another add in as a test and it wasn't displayed in the word ribbon.
When I check the Addin options in the Word option window the addin is located in the Active Application Addin which indicates that addin is loaded and working but still can't be displayed in the word ribbon.
I also tried to re-install the whole office package and restore the PC configuration to the date before installing the app but still nothing works.
The registry keys I use for the Addin are listed below:
Description: My_Addin
FriendlyName: My_Addin
LoadBehavior: 3 (DWORD (32-bit) value)
Manifest: file:///C:/Application folder/My_Addin.vsto|vstolocal

Cannot Develop Office 2010 Addin Using VS2013 or VS2015 with Office 365 Installed

I have Office 2010 installed (and Office 365 as it happens), and am trying to develop an Outlook 2010 Add-in using VS2013 and VB.
I create a new Outlook 2010 Add In. Compile and Run the default app ("ThisAddIn"). Outlook 2010 opens OK. So far so good. Exit Outlook 2010.
Save the OutlookAddIn project.
Close VS2013
Restart VS2013. Try to open the saved project/ .sln and then get a "One Way upgrade" splash screen. Why...????
Tried the "upgrade", and it fails. "One or more projects in the solution were not loaded correctly...etc etc"
Output windows shows: " The application for the project is not installed" (That seems to indicate the solution "thinks" it's looking for an Office version other than Office 2010, I believe)
Solution Explorer window shows "OutlookAddIn1(loading)...The project file will load in the background" and the "One-way upgrade" splash returns.
Cancel that.
Solution Explorer window now shows "OutlookAddIn1(needs migration)...The project file will load in the background".
I try "Reload Project" in solution explorer. It appears to do so.
I try to run the app again, I get a dialog saying " You cannot debug or run this project, because the required version of Microsoft Office application is not installed".
Check Project Properties and ALL references appear to have gone. (?????)
I've reinstalled VS2010 Tools. That didn't work either.
I have tried VS2015 and get exactly the same behavior.
So....... I uninstalled Office 365 completely. That didn't work either.
Any clues please?
I have solved the problem, but don't know for sure what caused it. I suspect there were some corrupted pointers in Windows that were "confusing" Outlook 2016 with Outlook 2010. The only clues I had to this were that in the Control Panel>Default Items>Set Your Default Programs, the default app for mail was shown as Outlook 2016, but its associated description was all about Outlook 2010.
So I did a complete uninstall of Office 365 (Office 2016) followed by a complete uninstall of Office 2010. I then cleaned out as many registry entries and folders associated with those as I could.
I then reinstalled Office 365, followed by Office 2010. Now I can develop an Outlook 2010 app in VS2013 or 2015 as normal. So the problem is apparently solved without knowing its cause.

How to deploy an Outlook macro?

I made an Outlook macro. How can I deploy it to use it on some other machine?
Do I follow the same steps I followed on my machine Tools-> Macros-> create new or is there another way to deploy as we do with the vb or C# projects?
No, you don't need to follow the same steps and re-record the entire macro from scratch. You can save the module containing the macro and import it in Outlook on the other machine.
In Outlook's VBA editor, right-click your module > Export File...
Then on the other machine, in Outlook's VBA editor, right-click your project > Import File...
EDIT You say that your Outlook doesn't have VB Editor. Quoting from Outlook help:
you may be running a Microsoft Office
program with the Visual Basic for
Applications (VBA) shared feature disabled.
I don't know what version of Outlook you have, but for 2003:
To re-enable VBA, follow these steps:
1.Run the Office Setup program again. How? Quit all programs.Double-click
the Add/Remove Programs icon in the
Microsoft Windows Control Panel.Do one
of the following: If you installed
your Office program as part of
Microsoft Office, click Microsoft
Office in the Currently installed
programs box, and then click the
Change button.If you installed your
Office program individually, click the
name of your program in the Currently
installed programs box, and then click
the Change button.
2.On the Features to install screen in the Setup program, click the plus sign
(+) next to Office Shared Features.
3.Select Visual Basic for Applications, click the arrow next to
your selection, and then click Run
from My Computer.
Usually outlook macros are only made for personnal use. Distributing them can be hard as it needs too much actions made by the user (add "devoloper" in ribbon, open visual basic editor, import files, enable references, enable security...).
Microsoft wrote:
If you are developing a solution that you intend to distribute to more than a few people, you should convert your VBA code into an Outlook COM or VSTO add-in or an Office add-in for Outlook.
(source: https://support.microsoft.com/en-us/help/290779/managing-and-distributing-outlook-visual-basic-for-vba).
Knowing that, i recommend you to write a VSTO add-in and deploy it using ClickOnce.
You can start by these links:
VSTO
https://learn.microsoft.com/en-us/visualstudio/vsto/getting-started-programming-vsto-add-ins?view=vs-2019
ClickOnce deployment
https://learn.microsoft.com/en-us/visualstudio/vsto/deploying-an-office-solution-by-using-clickonce?view=vs-2019

Problem installing VSTO4.0 addin on Outlook 2007

I have created an Outlook addin using VS2010 and VSTO 4.0.
On Windows7+Outlook 2010, the installation and and application behaves as expected.
On Vista+Outlook 2007 (fresh installed virtual machine), the installer complains that it does not recognize the .vsto file format.
Has anyone experienced this? When I previously created VSTO3.0 addins and used them on Outlook 2007 I had no problems with installation.
You need to install the VSTO 4.0 runtime (which comes pre-installed with 2010, but not with 2007). You can download it from Microsoft right here.
If you deploy using ClickOnce this runtime gets added to the prerequisites automatically.