{"id":2602,"date":"2024-01-17T10:25:34","date_gmt":"2024-01-17T18:25:34","guid":{"rendered":"https:\/\/systemsolver.com\/StatlerBlog\/?p=2602"},"modified":"2024-01-17T10:25:34","modified_gmt":"2024-01-17T18:25:34","slug":"libreoffice-writer-macro-code-samples","status":"publish","type":"post","link":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/2024\/01\/17\/libreoffice-writer-macro-code-samples\/","title":{"rendered":"LibreOffice Writer macro code samples"},"content":{"rendered":"<h3>Current file name, directory and full path<\/h3>\n<p>with help from a question I asked at <a href=\"https:\/\/ask.libreoffice.org\/t\/macro-function-regex-not-working\/97425\">https:\/\/ask.libreoffice.org\/t\/macro-function-regex-not-working\/97425<\/a><\/p>\n<pre>Sub CurrentFileLocation\n\tsUrl = ThisComponent.getURL()\n\t\n\t'To get the full path\n\tsFullPath = ConvertFromURL(sUrl)\n\t\n\t'Then to get the full path but no the file name\n\tsParts = Split(sFullPath,\"\\\")\n\tReDim Preserve sParts(0 to UBound(sParts) - 1)\n\t sDirectory = Join(sParts, \"\/\")\n\t \n\t'Then to get just the document name\n\tsParts = split(sUrl,\"\/\")\n\tsName =convertfromurl(sParts(ubound(sParts)))\n\t'ubound returns the last item in the array sParts\n\t\n\t'Then to see the results\n\tmsgbox(sName &amp; Chr$(13) &amp; sDirectory &amp; Chr$(13) &amp; sFullPath )\nend sub<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Current file name, directory and full path with help from a question I asked at https:\/\/ask.libreoffice.org\/t\/macro-function-regex-not-working\/97425 Sub CurrentFileLocation sUrl = ThisComponent.getURL() &#8216;To get the full path sFullPath = ConvertFromURL(sUrl) &#8216;Then to get the full path but no the file name sParts = Split(sFullPath,&#8221;\\&#8221;) ReDim Preserve sParts(0 to UBound(sParts) &#8211; 1) sDirectory = Join(sParts, &#8220;\/&#8221;) &#8216;Then [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2602","post","type-post","status-publish","format-standard","hentry","category-general"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts\/2602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/comments?post=2602"}],"version-history":[{"count":0,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts\/2602\/revisions"}],"wp:attachment":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/media?parent=2602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/categories?post=2602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/tags?post=2602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}