How to: Get and Set the Default File Path for Workbooks

The following examples show you how to get and set the default path that Microsoft Office Excel uses for loading and saving files.

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

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

Concepts

Working with Workbooks

NamedRange Control