Sub Main
    
    MsgBox(GetDocFullPath())
    
End Sub

' Returns document full path if document has a path. Returns empty string if   '
' document has no path and IgnoreNoPathError flag is set to TRUE.              '
Function GetDocFullPath(Optional IgnoreNoPathError as Boolean) As String
    
    ' Default behavior is to return empty string if document location is empty '
    ' This can happen if document is new and not saved thus do not have a path '
    If NOT ThisComponent.hasLocation() AND IgnoreNoPathError <> TRUE Then
        ' Err.Raise is not valid statement but will generate error anyway.     '
        Err.Raise("Document has no path. Probably because is not saved.")
    End If
    
    GetDocFullPath = ConvertFromURL(ThisComponent.getLocation())
    
End Function

Описание:
Вышепредставленный программный код на бейсике для макросов либреофиса можно использовать чтобы получить полный путь к текущему (над которым работает макрос) документу / файлу в обычном формате.


P.S. Присылайте криптовалюту если вам нравится то, что я делаю.
Если не нравится - тоже присылайте.
LTC (Litecoin): LLN6X2uV1iuQ1e4tdmQZsf2RRwh4pxPSej

Leave a Reply

*