Forum Discussion
Macro execute to loop all word doc files in a folder
- Oct 17, 2022
Also, to be on the safe side, I'd explicitly loop through Word documents, so that you don't get an error if the folder contains another type of file:
path = "C:\Users\hrhquek\Desktop\DEBT RECOVERY\Bizfile\" myFile = Dir(path & "*.doc*")
alright, i thought i would need to include "doc" and "docx" file type to have the code running. ok, so right now, the folder has 2 word document files.
Currently when the macro is executed, data from the 1st word document file was populated twice rather then both word documents file being populated.
Attaching the screenshot below:
Data in the 1st and 2nd column has been removed due to confidentiality.
JMB17 , appreciate the response. Bizfile is folder.
The macro works after inputting the "\" after the Bizfile and include the "*.docx*" but somehow it resulted in duplicate entries.
We don't know the code that is being called, but I notice that you open a document using oDoc as variable, but then close a document using a different variable wordDoc. Could that be the cause of the problem?