Creating Excel Automation add-in with VC++ - excel

I am newbie to Excel addins and Visual Studio. After some search, I came up with the following steps to create Excel automation addin: (I am using VS 2012)
create a C++ ATL project
add a STL Simple object
right-click on the object and add a method (with a IN and RETVAL parameters)
build the solution
register the dll with regsvr32
I am able to register the dll successfully. But the add-in does not show up in the Automation Servers available list in Excel 2010 (installed on my machine on Windows 7). Excel is 32 bit.
Thanks in advance

I was using the wrong regsvr32. Since I am building 32bit dll, I should be using regsvr32 from \Windows\SysWOW64.

Related

Make an Excel COM add-in a VSTO add-in

I have coded an Excel add-in using Visual C#. This add-in appears as a COM add-in in Excel. However, I am quite sure that it used to appear as an Excel/VSTO Add-In in Excel before an update of Visual Studio. (I know that I was able to access the Globals class. This thread says that Globals can only be accessed in Excel add-ins.)
So my question is: How can I make my COM add-in an Excel/VSTO add-in?
When you create an Office project, Visual Studio automatically generates a class named Globals in the project. You can use the Globals class to access several different project items at run time from any code in the project.
You can start writing your VSTO Add-in code in the ThisAddIn class. Visual Studio automatically generates this class in the ThisAddIn.vb (in Visual Basic) or ThisAddIn.cs (in C#) code file in your VSTO Add-in project. The Visual Studio Tools for Office runtime automatically instantiates this class for you when the Microsoft Office application loads your VSTO Add-in. Read more about that in the Program VSTO Add-ins article.
Also, see Walkthrough: Create your first VSTO Add-in for Excel.
Well, if you used Microsoft.Office.Interop.Excel.... thats COM... Interoperability. VSTO is a COM.

Deployment of Visual Studio Add-in in VS 2012

I have created Visual studio add-in successfully.But I am confused to deploy this addin in another computers.I have go throgh the stackoverflow answers.But I did not get clear cut idea about this matter
You just need to copy YourAddIn.dll and YourAddIn.AddIn files to "c:\Users\username\Documents\Visual Studio 2012\Addins\" folder on another computer. To create an installer you can start with Wix Template For VS2012 Addin Project.
Deploying an add-in requires to copy the add-in dll(s) to some folder and create a XML .AddIn file in a predefined folder where VS can locate it where a entry of the XML file points to the add-in assembly.
For articles about the prefedined folders for .AddIn files and about creating a setup see the "Articles about installing and uninstalling" section of my web site:
http://www.visualstudioextensibility.com/articles/add-ins/
To troubleshoot problems loading add-ins see my article:
HOWTO: Troubleshooting Visual Studio and Office add-ins
Visual Studio is a 32-bit executable, so the add-in dll and dependencies must be 32-bit.

Where are the Office PIA's installed?

I am writing an application in IIS that uses the Microsoft office excel automation library. I have downloaded the Office PIA from here and it downloaded an executable called PIARedist which I ran. This unpacked into 3 files o20120_eula.txt, o2012_readme.rtf and o2012pia which is a windows installer package. I ran the windows installer package, and that's where I got stuck, I expected it to unpack all of the libraries that I need, or put them somewhere in the file system, but nothing. The installer ran, but with no indication of what it was doing or what it was installing. Where do I go from here to obtain these libraries? And is developing on windows always this awful?
They live here:
C:\Program Files x86\Microsoft Visual Studio 14.0\Visual Studio Tools for Office\PIA
Where do I go from here to obtain these libraries?
They will have been installed in the GAC. After installing, you should be able to add a COM reference to Excel in Visual Studio, and it will reference the PIA assembly rather than generating an assembly with TLBIMP.
And applications that reference the PIA from that version of Office will be able to run.
And is developing on windows always this awful?
Not always, but more often than I'd like.
It turns out I just hadn't installed office on my machine. I assumed that it came preinstalled since there was an icon for it in the start menu, but that icon was what installed office.

Error deploying VSTO Office addin

I'm having some issues deploying a Visio addin.
Running the VSTO file works on my computer, but whenever I try and move it to any other user's computer it throws an error on deployment.
I thought it might be a setting I'd set in the project properties so I created an entirely new plugin project and set it to display a message box on startup.
The error I'm getting is:
An error occured during customization install.
The expected element "addIn" was not found in the XML.
This is caused by an issue with Clickonce.
I found a workaround by installing the addin using MSI.
This Guide was a lot of help.
Taken from the section about registry settings for the msi installation:
It is important to note the ‘|vstolocal’ value appended to the end of the Manifest value. This informs the VSTO runtime that it is locally installed and to not invoke the ClickOnce installer.
I'm having the same issue with our Word, Excel, Outlook and PowerPoint add-in. The installation of the msi runs perfect.
When starting Word for example, the Add-in itself gets 'installed' and then I receive the error.
I have added |vstolocal to the registry, which is located in the HKCU tree.
The projects is a Visual Studio 2010 project, build on TFS 2008. The installation on an Office 2010 goes well, the error only occurs when Office 2007 is on the machine.
Anything else I'm overseeing?
The solution to my experience with this issue was the one given by Joeri on the 8th July - install Visual Studio 2010 Tools for Office Runtime on the target machine.
This is an issue with the version of Visio your add-in targets versus what is installed on the client machine. AddIn is an element that is new with the 2007 versions of Office. More than likely the client is running Visio 2003.
Some times the Visual Studio 2010 Tools for Office Runtime is installed on the machine but the vsto file fails to find it. In this case try if you can manually execute the installation command line.See example below (replace X with your own drive letter, path, and file name):
"c:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe" /Install file:///X:/XXX/XXX.vsto 

Not a valid Office Add In

I developed a new Office 2007 addin using VS 2008 and VSTO. after this I go to
Office->Excel Options->AddIns->COM AddIns and GO... If I select the .dll which I ve created I get the error
'<path>' is not a valid Office Add In.
If I run it using the Visual Studio 2008 at my development machine, it works fine and I see the add-in.
I searched so many posts but didn't get a solution.
Excel kept rejecting the Add-In, so the solution for me was doing it directly via the registry.
Save the below text as a .reg file, replace the Manifest path and FriendlyName to suit your PROJECT and double click the reg file to add the key to the Registry.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins\PROJECTExcelAddIn]
"Manifest"="file:///C:\\TFS\\Pg.PROJECT\\PROJECTExcelAddIn\\Src\\PROJECTExcelAddIn\\PROJECTExcelAddIn\\bin\\Debug\\PROJECTExcelAddIn.vsto"
"FriendlyName"="PROJECTExcelAddIn"
"LoadBehavior"=dword:00000003
"Description"="PROJECTExcelAddIn - Excel add-in for PROJECT."
VSTO does not create COM Addins. You will need to install your add-in on non-development machines. The article Adding the Office Primary Interop Assemblies as a Prerequisite in your ClickOnce installer at http://blogs.msdn.com/vsto/archive/2008/05/08/adding-the-office-primary-interop-assemblies-as-a-prerequisite-in-your-clickonce-installer-mary-lee.aspx will get you started.
Actually, you'll have to publish the addin. Then, the Visual Studio will create a folder in Debug folder named app.publish folder with other folders in and, the important thing, a setup file named setup.exe.

Resources