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ステートメントで対処できます。

Error codes:

5 無効なプロシージャー呼び出しです

68 デバイスが使用できません

76 パスが見つかりません

Example:


  Sub ExampleChDrive
      ChDrive "D"  REM ドライブ「D」が存在する場合にのみ有効
  End Sub

ご支援をお願いします!