What is VSTO exactly? - vsto

I have a few add-ins for Excel and Word 2007-2016. And I don't understand a few things. My project use some dlls, like Microsoft.Office.Tools.Common, Office.dll, some excel, word and common interop's. And these files can be found in a few places at the same time, different versions of them (like program files, windows/assembly, windows/Microsoft.Net/assembly). So I don't know which version to use. And also, if user has VSTO installed, I suppose he has these files. So why do I need to provide them? What do we install exactly when we install VSTO? Which part is for what and which installation place is from which component? I think I don't do it right, because I found out that Excel loads two different versions of the same file at the same time.

Those are a lot of questions, and many of them depend very much on exactly what you provide with your solution...
The case of the PIAs ("Office dlls") is relatively clear cut:
You do NOT need to (and should not) distribute the Office PIAs with a VSTO solution, with the possible exceptions of 2007 and 2010. In these versions, installing .NET support was optional and not default. That's why there are redistributables for these versions, and not for others. Your installer needs to check whether they're present (same as with the VSTO runtime and the version of the .NET Framework) and install only when necessary.
Office always installs the PIAs into the GAC and your solution will find them there. It makes no difference where you referenced them on your developer machine.
The PIAs in the GAC are only available via the COM tab in the Visual Studio dialog box for inserting references. Many .NET developers didn't find them there, so Microsoft delivers a (ONE) single set of PIAs with VSTO and copies them to a Visual Studio folder so that they'll show up in the .NET tab of the dialog box. The only problem with this is that you get only the set of PIAs for the version of Office that was "current" when that version of Visual Studio was released, meaning you may get the impression you can't develop against any other version because you don't find the PIAs in the .NET tab (but they will be in the COM tab).
Rule of thumb: Always, always develop your code using the earliest version of Office you plan to support. There are two reasons for this: 1) You can only use functionality that will be available to all versions of the Office application (Office is generally backwards compatible); 2) Office is designed to migrate references to older sets of PIAs to newer sets, but not the other way around.
There's a good article on deployment pinned at the top of the VSTO forum on MSDN that "sorts" a lot of requirements for various versions of VSTO and Office: https://social.msdn.microsoft.com/Forums/vstudio/en-US/1666d2b0-a4d0-41e8-ad86-5eab3542de1e/deploying-office-solutions-to-end-user-computers?forum=vsto for add-ins targeting 2007-2010. For later versions, see the MSDN documentation: https://msdn.microsoft.com/en-us/library/bb386179.aspx

Related

I cannot access the Excel interop from my VB program

I have had to replace my laptop. One of the applications I have needed to install is Visual Studio Community 2019 since I rely on some programs which I wrote in VB. My memory of the 2015 version is that I just installed it. With the 2019 version, I must specify which components I need. Given how many components are available, I can see why they cannot install everything. I need access the Excel interop and have downloaded every component that might give access to the interop without any apparent success. The statement Imports Excel = Microsoft.Office.Interop.Excel gives the error “{) Namespace Microsoft. Namespace or type specified in the Imports ‘Microsoft.Office.Interop.Excel’ does not contain any public member or cannot be found.”
Searching for help, I found: “to use the features of a Microsoft Office application from an Office project, you must use the primary interop assembly (PIA) for the application.” For my 64-bit computer, these should, apparently, be installed in “%ProgramFiles(x86)%\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\”.
I find that folder “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\” contains subfolders “Office14” and “Office15”. Each of these subfolders contains a different set of PIAs. Both contain “Microsoft.Office.Interop.Excel.dll” with the Office 14 version dated 31Mar2015 and the Office 15 version dated 7Oct2015.
I use Office version 15. Should I move the PIAs I want from folder “PIA\Office15” to folder “PIA” or have I misunderstood something else?
You can try to install the Nuget package Microsoft.Office.Interop.Excel form Nuget Package Manager.
First, right click the project and select Manage NuGet Packages....
Then type Microsoft.Office.Interop.Excel in the search bar and install it:
Kyle Wang’s answer allowed me to solve my problem. However, his images and descriptions differed from my experience with Visual Studio 2019. I suspect he uses an earlier version. This answer documents my experience with Visual Studio Community 2019 in the hope that other can benefit from my troubles.
With Visual Studio 2015, the version I have been using, only Visual Studio is installed. With Visual Studio 2019, Visual Studio Installer is also installed.
If I open Visual Studio Installer I see:
If I click Modify, I see:
If I scroll down a little I see:
The blue ticks in the righthand corner identify the workloads I have already installed.
If I click Individual Components, I see:
I am unsure which components were downloaded because they were included in a selected workload and which were downloaded because I selected every component that might include the Excel InterOp I was looking for. I will probably uninstall Visual Studio and re-install now I know what I need.
If I scroll down enough, I see:
I definitely needed to download NuGet package manager if I want access to the Excel InterOp. I do not know if I needed NuGet targets and build tasks. If I re-install Visual Studio I will try without NuGet targets and build tasks and update this answer to report if it is needed. I have not found any documentation describing the significance of these components, so it seems you need to experiment to determine what components you need.
Once you have selected the workloads and or individual components you want, click Modify in the bottom righthand corner. A progress screen is displayed while the installation is performed. When it has finished, close Visual Studio Installer.
Open Visual Studio 2019 and then create or open the solution that requires the Excel InterOp. The fourth tab in the top row is Project. Click it. The bottom but one line in the dropdown menu is Manage NuGet Packages…. Click it. You will see:
Click Browse to get:
https://www.nuget.org/ claims they hold 2,031,503 versions of 181,450 unique packages. As far as I can tell, they are displayed in order of download numbers. For example, Newtonsoft.Json has been downloaded 320.5 million times. To find any particular package you must use search. Searching for “microsoft.office.interop” reduces the list to something manageable with the Excel Interop at the top. Select the package you need and click Install on the right.

Universal MS Word plug-in for Windows and Mac

I am looking for the way to implement MS Word plug-in for Mac and Windows. The plug-in should work with all versions of Microsoft Office (Microsoft Office 2003, Microsoft Office 2007, Microsoft Office 2010, Microsoft Office 2013, Microsoft Office 2016) and should work on Windows XP - Windows 10. It should work on MS Word on Mac also (at least on the latest versions).
It seems to be impossible to create one app for all of this OS and versions.
Description of the plug-in: The plug-in should help user to find the definition of any word (the definition will be in the beginning of this file or in the other file on the user's local disk). For example, user place mouse over word "math", a plug-in shows pop-up with definition "Mathematics (from Greek μάθημα máthēma, “knowledge, study, learning”) is the study of topics such as quantity (numbers), structure, space and change".
I am thinking about some variants of implementation.
First variant. I can make plug-in with help of WinForms and Microsoft.Office.Interopt for all Windows OS and versions of MS Office. I can create add-ins for Word on Mac with help of JavaScript. (Add-ins on JavaScript don't work on Microsoft Office versions < 2013).
Second variant. I can create plug-in with help of VBA for both platform and for all versions.
Are these variants possible? What the best way to create plug-in for Windows and Mac?
First variant. I can make plug-in with help of WinForms and Microsoft.Office ...
This, sound to me, way you should go if you would like to support older Office products (2010 and older). You would create VBA or COM/VSTO version for older versions on Windows. For older versions of Mac (ex:Entourage) you should consider AppleScript scripting extendability. Office Add-in (JS API) for newer versions on Windows and Mac together.
Second variant. I can create plug-in with help of VBA for both platform and for all versions.
No such thing as VBA add-on for Mac. You may efficiently use AppleScript for scripting certain actions in older Office for Mac.
This is all about your requirements. At the end you will make your decision. I would go with Office JS API as the start and later on see if you have strong demand of your app for older versions of Office.
Yes it is possible, but refine your requirement.
Go for Apps for Office (Windows + Mac) and not Com Add-ins (Only in Windows).

How to do a project/modify a existing project in VB

I have no idea/experience in VB programming. One of my client bought me his old project which need to be modified. He says it is written in Visual Basic and no idea which version.
So how can i carry ON to work with this project by identifying the version
And what other components do i require to do the programming and user interface.
I already have Visual studio 2010 with me. So can i do my work using this software or i have to go for anything else...
Any suggestions....?
Regards
ParshTest
You need to check the earlier VS version. If the project was developed in earlier version of VS, you can upgrade to VS 2010 easily but otherwise you need to get hands on specific VS version.
Similarly if the project have database functionality or crystal report or any other external dependencies, you need to check their versions. You need to install the components according to these versions. Specify your versions and i'll tell you what to use for further development.

Which library does DBCombo come from?

I'm having some compatibility issues with a legacy VB5 program I inherited.
Specifically, the DBCombo control.
Where does this control come from? I think it might be from the Microsoft DAO Object Library but I want to make sure.
It is, well, was, an ActiveX control last seen in VB6. The DLL that supported it was named "DBList32.ocx". If you have a really old machine on which it was installed then you could copy that file from the c:\windows\system32 directory and register it with regsvr32.exe.
I can still add it to the VS2008 .NET toolbox by right-clicking it and selecting Choose Items, COM tab and ticking "Microsoft DBCombo Control" (got VB6 installed on the machine). Didn't actually try to use it, odds are low after the Windows 7 SP1 update for ADO that broke backwards compatibility.

Where to download Microsoft Visual c++ 2003 redistributable

I have an old dll that uses the Microsoft Visual C++ 2003 (7.1) run time package. Unfortunately I don't have that DLL around anymore. Short of reinstalling VS2003, is there another way to get the run time redistributable dll?
Storm's answer is not correct. No hard feelings Storm, and apologies to the OP as I'm a bit late to the party here (wish I could have helped sooner, but I didn't run into the problem until today, or this stack overflow answer until I was figuring out a solution.)
The Visual C++ 2003 runtime was not available as a seperate download because it was included with the .NET 1.1 runtime.
If you install the .NET 1.1 runtime you will get msvcr71.dll installed, and in addition added to C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322.
The .NET 1.1 runtime is available here: http://www.microsoft.com/downloads/en/details.aspx?familyid=262d25e3-f589-4842-8157-034d1e7cf3a3&displaylang=en (23.1 MB)
If you are looking for a file that ends with a "P" such as msvcp71.dll, this indicates that your file was compiled against a C++ runtime (as opposed to a C runtime), in some situations I noticed these files were only installed when I installed the full SDK. If you need one of these files, you may need to install the full .NET 1.1 SDK as well, which is available here: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9b3a2ca6-3647-4070-9f41-a333c6b9181d (106.2 MB)
After installing the SDK I now have both msvcr71.dll and msvcp71.dll in my System32 folder, and the application I'm trying to run (boomerang c++ decompiler) works fine without any missing DLL errors.
Also on a side note: be VERY aware of the difference between a Hotfix Update and a Regular Update. As noted in the linked KB932298 download (linked below by Storm): "Please be aware this Hotfix has not gone through full Microsoft product regression testing nor has it been tested in combination with other Hotfixes."
Hotfixes are NOT meant for general users, but rather users who are facing a very specific problem. As described in the article only install that Hotfix if you are have having specific daylight savings time issues with the rules that changed in 2007. -- Likely this was a pre-release for customers who "just couldn't wait" for the official update (probably for some business critical application) -- for regular users Windows Update should be all you need.
Thanks, and I hope this helps others who run into this issue!
After a bit of googling, it seems that there never was a separate redistributable for Visual C++ 2003 (7.1). At least that is what a post on the microsoft forum says.
You may however be able to extract the runtime DLLs from the VC 7.1 DST timezone update.
the answer https://stackoverflow.com/a/6132093/1498669 is right.
There is also an update to both 2002 and 2003 runtimes
just do an search on microsoft download
https://www.microsoft.com/en-us/search?q=mfc70
https://www.microsoft.com/en-us/search?q=mfc71
and you find the offical updates to the products
however, the latest patches seem to be:
https://www.microsoft.com/en-us/download/details.aspx?id=3644
https://www.microsoft.com/en-us/download/details.aspx?id=22539
https://www.microsoft.com/en-us/download/details.aspx?id=6818
Another way:
using Unofficial (Full Size: 26.1 MB) VC++ All in one that contained your needed files:
http://www.wincert.net/forum/topic/9790-aio-microsoft-visual-bcfj-redistributable-x86x64/
OR (Smallest 5.10 MB) Microsoft Visual Basic/C++ Runtimes 1.1.1 RePacked Here:
http://www.wincert.net/forum/topic/9794-bonus-microsoft-visual-basicc-runtimes-111/
I think this is what you're looking for: Microsoft Visual C++ 2008 Redistributable Package (x86)