{"id":65,"date":"2019-04-04T22:58:11","date_gmt":"2019-04-04T22:58:11","guid":{"rendered":"https:\/\/keithratner.live\/optionexplicit\/?p=65"},"modified":"2019-11-22T02:11:24","modified_gmt":"2019-11-22T02:11:24","slug":"deleteallfilesinfolder","status":"publish","type":"post","link":"https:\/\/keithratner.live\/optionexplicit\/deleteallfilesinfolder\/","title":{"rendered":"DeleteAllFilesInFolder"},"content":{"rendered":"<pre>Public Sub DeleteAllFilesInFolder( _\n    strPathToFolder As String _\n)\n    Dim _\n        fs As Object, _\n        fldr As Object, _\n        f As Object\n    Set fs = CreateObject(\"Scripting.FileSystemObject\")\n    Set fldr = fs.GetFolder(strPathToFolder)\n    For Each f In fldr.Files\n        Application.StatusBar = _\n            \"Deleting file \" &amp; _\n            f.Name &amp; _\n            \" from folder \" &amp; _\n            strPathToFolder\n        DoEvents\n        f.Delete True\n    Next\n    Set f = Nothing\n    Set fldr = Nothing\n    Set fs = Nothing\n    Application.StatusBar = False\nEnd Sub<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Public Sub DeleteAllFilesInFolder( _ strPathToFolder As String _ ) Dim _ fs As Object, _ fldr As Object, _ f As Object Set fs = CreateObject(&#8220;Scripting.FileSystemObject&#8221;) Set fldr = fs.GetFolder(strPathToFolder) For Each f In fldr.Files Application.StatusBar = _ &#8220;Deleting file &#8221; &amp; _ f.Name &amp; _ &#8221; from folder &#8221; &amp; _ strPathToFolder DoEvents f.Delete [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":69,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[114],"tags":[148,151,160],"class_list":["post-65","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippet","tag-file","tag-folder","tag-path"],"krwpengineoptions-featuredonwpengineblog":"","jetpack_featured_media_url":"https:\/\/i0.wp.com\/keithratner.live\/optionexplicit\/wp-content\/uploads\/sites\/29\/2019\/04\/deleteallfilesinfolder.png?fit=389%2C343&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pgsIIA-13","jetpack-related-posts":[{"id":175,"url":"https:\/\/keithratner.live\/optionexplicit\/folderexists\/","url_meta":{"origin":65,"position":0},"title":"FolderExists","author":"Keith","date":"July 8, 2019","format":false,"excerpt":"Function FolderExists( _ strCompleteFolderPath As String _ ) As Boolean Dim _ fs As Object Set _ fs = _ CreateObject( _ \"Scripting.FileSystemObject\" _ ) FolderExists = _ fs.FolderExists( _ strCompleteFolderPath _ ) Set _ fs = _ Nothing End Function","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":150,"url":"https:\/\/keithratner.live\/optionexplicit\/getbasename\/","url_meta":{"origin":65,"position":1},"title":"GetBaseName","author":"Keith","date":"May 2, 2019","format":false,"excerpt":"Public Function GetBaseName( _ sFullFileNameWithExtension As String _ ) Dim fs As Object Set fs = CreateObject(\"Scripting.FileSystemObject\") GetBaseName = _ fs.GetBaseName( _ sFullFileNameWithExtension _ ) Set fs = Nothing End Function","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":155,"url":"https:\/\/keithratner.live\/optionexplicit\/getfilenamefromfullpath\/","url_meta":{"origin":65,"position":2},"title":"GetFileNameFromFullPath","author":"Keith","date":"May 6, 2019","format":false,"excerpt":"Public Function GetFileNameFromFullPath( _ sFullFileNameWithPath As String _ ) as String Dim fs As Object Set fs = CreateObject(\"Scripting.FileSystemObject\") GetFileNameFromFullPath = _ fs.GetFilename( _ sFullFileNameWithPath _ ) Set fs = Nothing End Function","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":179,"url":"https:\/\/keithratner.live\/optionexplicit\/getfileextension\/","url_meta":{"origin":65,"position":3},"title":"GetFileExtension","author":"Keith","date":"August 12, 2019","format":false,"excerpt":"Public Function GetFileExtension( _ sFullFileNameWithPath As String _ ) As String Dim fs As Object Set fs = CreateObject(\"Scripting.FileSystemObject\") GetFileExtension = _ fs.GetExtensionName( _ sFullFileNameWithPath _ ) Set fs = Nothing End Function","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":169,"url":"https:\/\/keithratner.live\/optionexplicit\/getfilepath\/","url_meta":{"origin":65,"position":4},"title":"GetFilePath","author":"Keith","date":"June 5, 2019","format":false,"excerpt":"Public Function GetFilePath( _ sFullFileNameWithPath As String _ ) As String Dim fs As Object Set fs = CreateObject(\"Scripting.FileSystemObject\") GetFilePath = _ fs.GetAbsolutePathName( _ sFullFileNameWithPath _ ) End Function","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":35,"url":"https:\/\/keithratner.live\/optionexplicit\/export-modules-to-folder\/","url_meta":{"origin":65,"position":5},"title":"Export Modules to Folder","author":"Keith","date":"April 3, 2019","format":false,"excerpt":"This will create a folder using the base name of your Excel file, which is the filename without its extension, along with a vba subfolder. Your VBA modules will be placed there. Pass UseTimestamp:=True to put each export in its own timestamped subfolder so repeated runs don't overwrite earlier exports.\u2026","rel":"","context":"In &quot;Snippet&quot;","block_context":{"text":"Snippet","link":"https:\/\/keithratner.live\/optionexplicit\/category\/snippet\/"},"img":{"alt_text":"Export Modules","src":"https:\/\/i0.wp.com\/keithratner.live\/optionexplicit\/wp-content\/uploads\/sites\/29\/2019\/04\/4-4-2019-2-16-36-AM.png?fit=665%2C496&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/keithratner.live\/optionexplicit\/wp-content\/uploads\/sites\/29\/2019\/04\/4-4-2019-2-16-36-AM.png?fit=665%2C496&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/keithratner.live\/optionexplicit\/wp-content\/uploads\/sites\/29\/2019\/04\/4-4-2019-2-16-36-AM.png?fit=665%2C496&ssl=1&resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":3,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":222,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/posts\/65\/revisions\/222"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/media\/69"}],"wp:attachment":[{"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/keithratner.live\/optionexplicit\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}