Search code examples
c#visual-studioms-officeoffice-interopglobal

How do I use the Globals class in Console Application?


I'm trying to use the Globals class in a Console Application.According to MSDN documentation,Globals is a class that Visual Studio automatically generates when you create an Office project.My question,can I use this class in a Console Application?I added references to Interop and Microsoft Office but I still cannot access the class.

Here is the link: https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/vsto/global-access-to-objects-in-office-projects.md


Solution

  • The documentation to which you link is for Visual Studio Tools for Office (VSTO) - a special library that runs in-process in an Office application. These namespaces cannot be used in Console or WinForms applications, only in Office Add-ins or document-level customizations.

    Note that the documents on GitHub are the same as what is found on learn.microsoft.com, but with less "context". For information purposes it's better to use "docs" and not GitHub.