How to: Get and Set the Default File Path for Workbooks
Applies to |
---|
The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office. Project type
Microsoft Office version
For more information, see Features Available by Application and Project Type. |
The following examples show you how to get and set the default path that Microsoft Office Excel uses for loading and saving files.
To get the default save path
Use the DefaultFilePath property of the _Application object to get the default path.
System.Windows.Forms.MessageBox.Show(Me.Application.DefaultFilePath)
System.Windows.Forms.MessageBox.Show(this.Application.DefaultFilePath);
To set the default save path
Assign a string value to the DefaultFilePath property of the Application object.
Me.Application.DefaultFilePath = "C:\temp"
this.Application.DefaultFilePath = @"C:\temp";
See Also
Tasks
How to: Read from and Write to Document Properties