共用方式為


HOW TO:取得及設定活頁簿的預設檔案路徑

更新:2007 年 11 月

適用於

本主題中的資訊僅適用於指定的 Visual Studio Tools for Office 專案和 Microsoft Office 版本。

專案類型

  • 文件層級專案

  • 應用程式層級專案

Microsoft Office 版本

  • Excel 2003

  • Excel 2007

如需詳細資訊,請參閱依應用程式和專案類型提供的功能

下列範例示範如何取得及設定 Microsoft Office Excel 用來載入和儲存檔案的預設路徑。

若要取得預設儲存路徑

  • 請使用 _Application 物件的 DefaultFilePath 屬性,取得預設路徑。

    System.Windows.Forms.MessageBox.Show(Me.Application.DefaultFilePath)
    
    System.Windows.Forms.MessageBox.Show(this.Application.DefaultFilePath);
    

若要設定預設儲存路徑

  • 將字串值指派給 Application 物件的 DefaultFilePath 屬性。

    Me.Application.DefaultFilePath = "C:\temp"
    
    this.Application.DefaultFilePath = @"C:\temp";
    

請參閱

工作

HOW TO:從文件屬性中讀取及寫入

概念

使用活頁簿

NamedRange 控制項