{"id":162,"date":"2012-12-16T19:51:15","date_gmt":"2012-12-16T18:51:15","guid":{"rendered":"http:\/\/mariaevert.dk\/vba\/?p=162"},"modified":"2012-12-16T19:51:15","modified_gmt":"2012-12-16T18:51:15","slug":"vba-get-name-of-file-without-extension","status":"publish","type":"post","link":"https:\/\/mariaevert.dk\/vba\/?p=162","title":{"rendered":"VBA &#8211; Get name of file without extension"},"content":{"rendered":"<p>The easiest way to get the name of a file is of course to use <code>ThisWorkbook.Name<\/code>. It will supply you with the name and the extension of the file (for example &#8220;MyWorkbook.xlsx&#8221;).But if you want to retrieve only the name the workbook and not the extension, you&#8217;ll need this: <\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nDim NameOfWorkbook\r\n\r\nNameOfWorkbook = Left(ThisWorkbook.Name, (InStrRev(ThisWorkbook.Name, &quot;.&quot;, -1, vbTextCompare) - 1))\r\n<\/pre>\n<p>It uses the function InStrRev to find the last occurance of &#8220;.&#8221; and the Left() function is then used to assign all chars left of this position to the NameOfWorkbook variable. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The easiest way to get the name of a file is of course to use ThisWorkbook.Name. It will supply you with the name and the extension of the file (for example &#8220;MyWorkbook.xlsx&#8221;).But if you want to retrieve only the name the workbook and not the extension, you&#8217;ll need this: It uses the function InStrRev to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=\/wp\/v2\/posts\/162"}],"collection":[{"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=162"}],"version-history":[{"count":6,"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":168,"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions\/168"}],"wp:attachment":[{"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mariaevert.dk\/vba\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}