Share via


Using My in Office Projects

In Visual Basic, you can use the keyword My to quickly and easily access information and default object instances that are related to the application and its run time environment. Office projects enable the use of the My keyword with the same functionality that is available in a Class Library project, which is a subset of the My objects supported in Windows Application projects.

Applies to: The information in this topic applies to document-level projects and application-level projects for Microsoft Office 2010 and the 2007 Microsoft Office system. For more information, see Features Available by Office Application and Project Type.

My Objects in Office Projects

The following My objects are available in Office projects.

Application

Provides properties, methods, and events related to the current application. For more information, see My.Application Object.

User

Provides access to the current user's security context. My.User is not set by default in Office projects. The output of an Office project is a DLL file that can potentially be called from multiple copies of an Office document. To get the correct user identity, you must add the following code to set the identity to that of the user running the application that is calling the DLL file:

My.User.InitializeWithWindowsUser()

For more information, see My.User Object.

Computer

Provides properties for manipulating computer components, such as audio, the clock, the keyboard, and the file system. For more information, see My.Computer Object.

WebServices

Provides properties for creating and accessing a single instance of each XML Web service referenced by the current project. All of the My.Webservices functionality is included. For more information, see My.WebServices Object.

Settings

Provides access to the application's settings and allows you to dynamically store and retrieve property settings and other information for your application. My.Settings functionality is included. For more information, see My.Settings Object.

Resources

Provides access to the application's resources and allows you to dynamically retrieve resources for your application. My.Resources functionality is included. For more information, see My.Resources Object.

See Also

Other Resources

Development with My (Visual Basic)

Getting Started (Office Development in Visual Studio)