[FONT="]I have several individual word files in a folder and one word file that is a merged version of all those word files. I would like to delete all the individual word files after the merge process, so only the Merged Word document remains. (I'm running this code via Excel, not Word)[/FONT]
[FONT="]Any ideas on coding? I'm thankful for all replies![/FONT]
[FONT="]I've been playing around with something like this but it doesn't work:[/FONT]
<code class="s14dydj4-7 cOzydF" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 13px; line-height: 20px; font-family: "Noto Mono", Menlo, Monaco, Consolas; vertical-align: baseline; background: transparent; color: rgb(34, 34, 34); max-width: 100%; overflow: auto;"> Sub test()
Dim myFile As String
Dim mypath As String
Dim objWord As Object
mypath = ThisWorkbook.Worksheets(2).Cells(4, 2).Value & "" 'filepath
myFile = Dir(mypath & "*.docx", vbNormal + vbReadOnly + vbHidden) ' all docx files in the filepath
MergeOutput = mypath & "ConsolidatedMerge" & "_" & Format(Now, "d_mmm_yyyy_hh_mm_ss") 'name of merged file
While myFile.Name <> MergeOutput
myFile.Delete
myFile = Dir(mypath & "*.docx", vbNormal + vbReadOnly + vbHidden)
Wend
End Sub
</code>[FONT="]Thanks in advance[/FONT]
[FONT="]Annabelle[/FONT]
[FONT="]Any ideas on coding? I'm thankful for all replies![/FONT]
[FONT="]I've been playing around with something like this but it doesn't work:[/FONT]
<code class="s14dydj4-7 cOzydF" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 13px; line-height: 20px; font-family: "Noto Mono", Menlo, Monaco, Consolas; vertical-align: baseline; background: transparent; color: rgb(34, 34, 34); max-width: 100%; overflow: auto;"> Sub test()
Dim myFile As String
Dim mypath As String
Dim objWord As Object
mypath = ThisWorkbook.Worksheets(2).Cells(4, 2).Value & "" 'filepath
myFile = Dir(mypath & "*.docx", vbNormal + vbReadOnly + vbHidden) ' all docx files in the filepath
MergeOutput = mypath & "ConsolidatedMerge" & "_" & Format(Now, "d_mmm_yyyy_hh_mm_ss") 'name of merged file
While myFile.Name <> MergeOutput
myFile.Delete
myFile = Dir(mypath & "*.docx", vbNormal + vbReadOnly + vbHidden)
Wend
End Sub
</code>[FONT="]Thanks in advance[/FONT]
[FONT="]Annabelle[/FONT]