CurDir Function

Returns a variant string that represents the current path .


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.


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


CurDir [(Text As String)]

GIá trị trả về:



Text: Any string expression that specifies an existing drive, for example "C" for the first partition of the first hard drive. This parameter is used solely under Windows.

If no drive is specified or if the drive is a zero-length string (""), CurDir returns the path for the current drive. LibreOffice Basic reports an error if the syntax of the drive description is incorrect or if the drive does not exist.

Hàm này không phân biệt chữ hoa/thường.

Error codes:

5 Sai gọi thủ tục

68 Thiết bị không sẵn sàng 68 Thiết bị không sẵn sàng 68 Thiết bị không sẵn sàng

7 Cạn bộ nhớ

51 Lỗi nội bộ 51 Lỗi nội bộ 51 Lỗi nội bộ 51 Lỗi nội bộ


  Sub ExampleCurDir
      Dim sDir1 As String, sDir2 As String
      sDir1 = "C:\Test"
      sDir2 = "D:\Private"
      ChDir( sDir1 )
      MsgBox CurDir
      ChDir( sDir2 )
      MsgBox CurDir
  End Sub

Please support us!