ChDrive Statement

變更目前磁碟機。

warning

Some DOS-specific file and directory functions are no longer provided in LibreOffice, or their function is only limited. For example, support for the ChDir, ChDrive and CurDir functions is not provided. Some DOS-specific properties are no longer used in functions that expect file properties as parameters (for example, to differentiate from concealed files and system files). This ensures the greatest possible level of platform independence for LibreOffice. Therefore this feature is subject to removal in a future release.


note

The ScriptForge library in LibreOffice 7.1 introduces the FileSystem service with methods to handle files and folders in user scripts.


Syntax:


  ChDrive Text As String

Parameters:

Text:包含新磁碟機號的任意字串型表示式。如果需要,您也可以使用 URL 表示法。

磁碟機號必須使用大寫字母。在 Windows 環境下,為磁碟機指定的字母受 LASTDRV 設定的限制。如果磁碟機引數是一個多字元字串,則只會採用第一個字母。如果嘗試存取不存在的磁碟機,則發生錯誤。透過 OnError 陳述式可以對這個錯誤做出回應。

錯誤代碼:

5 無效的程序呼叫

68 裝置不可用

76 找不到路徑

Example:


  Sub ExampleChDrive
      ChDrive "D"  REM 必須存在磁碟機「D」。
  End Sub

Please support us!