Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

附註: 如果 Microsoft Jet Expression Service 在沙箱模式中執行,會停用本主題中所述的函數、方法、物件或屬性,以免評估可能不安全的表達式。 如需沙盒模式的詳細資訊,請在 [說明] 中搜尋「沙盒模式」。

傳回代表目前路徑的 Variant (String) 。

語法

CurDir[ (磁碟驅動器) ]

選用磁 碟驅動器引數 是指定現有磁碟驅動器的 字串運算式 。 如果未指定磁碟驅動器,或是 磁碟驅動器 是零長度字串 (“) ,CurDir 傳回目前磁碟驅動器的路徑。 在 Macintosh 上, CurDir 會忽略任何指定的 磁碟驅動器 ,只要傳回目前磁碟驅動器的路徑即可。

範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

此範例使用 CurDir 函數傳回目前的路徑。 在 Macintosh 上,指定給 CurDir 的磁碟驅動器規格會被忽略。 默認磁碟驅動器名稱為「HD」,路徑名稱的一部分會以冒號而非反斜杠分隔。 同樣地,您會指定 Macintosh 資料夾,而不是 \Windows。

' Assume current path on C drive is "C:\WINDOWS\SYSTEM" (on Microsoft Windows).
' Assume current path on D drive is "D:\EXCEL".
' Assume C is the current drive.
Dim MyPath
MyPath = CurDir ' Returns "C:\WINDOWS\SYSTEM".
MyPath = CurDir("C") ' Returns "C:\WINDOWS\SYSTEM".
MyPath = CurDir("D") ' Returns "D:\EXCEL".

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×