Hello
I have no idea where your problem is.
I think you will need to step through the macro in Debug mode yourself and follow through yourself to locate where the problem is
Example: I try the macro again…
This code line
DocWithImgs.SaveAs FileName:=strPath & "" & strDocumentName & ".htm", FileFormat:=wdFormatHTML
makes the .htm file and the _____-Files
https://i.postimg.cc/66ZRRYJK/Made-2...ECORDS-htm.jpg https://i.postimg.cc/J4WXQZMk/Files-are-made.jpg
This code bit makes the directory MovedToHere
If Dir(strPath & "\MovedToHere", vbDirectory) = "" Then MkDir strPath & "\MovedToHere"
https://i.postimg.cc/YSygNPCr/Direct...re-is-made.jpg
If you step through this code section, you should see it looping and copying files
As it loops you will see the folder MovedToHere being filledCode:Do While strFile <> "" ' The purpose of the Do While __ Loop _ loop is to keep going while you still find files of the extension type currently being looked for. Name strPath & "\" & FileFlder & "\" & strFile As strPath & "\MovedToHere\" & "New " & strFile ' Each of the files you find gets copied to folder, MovedToHere and has its name modified a bit to have the text "New " added at the start, like for example, Filex.png would become New Filex.png Let strFile = Dir ' The use of Dir on its own, without any bracket ( ) stuff tells VBA to look again for the next file of the same type and in the same place that it looked the last time Loop ' While strFile <> ""
https://i.postimg.cc/mrrCH4Rp/Direct...ing-filled.jpg
https://i.postimg.cc/6pcCqqsG/Direct...ing-filled.jpg
https://i.postimg.cc/bJDnmRZQ/Direct...ing-filled.jpg
https://i.postimg.cc/6qCvX5Lq/Direct...ing-filled.jpg
https://i.postimg.cc/cHpn283P/Direct...ing-filled.jpg
https://i.postimg.cc/x1nK9HZ2/Direct...ere-filled.jpg
This code bit
If Not Dir(strPath & "" & FileFlder & "\*.*") = "" Then Kill strPath & "" & FileFlder & "\*.*"
empties the ___-Files folder
https://i.postimg.cc/BQxTWNMp/File-f...les-killed.jpg
If you do not know how to step through in Debug F8 mode in VBA , then …..
Get into the vbeditor ( Key Alt+F11 from Excel ) , and click anywhere in the macro
https://i.postimg.cc/kGrB53fH/get-into-macro.jpg
Hit key F8
This will step you through the macro , one line at a time
https://i.postimg.cc/R0DWjnf4/Steping-through-in-F8.jpg
https://i.postimg.cc/d1Zhvtmd/Steping-through-in-F8.jpg
https://i.postimg.cc/fbL32vV8/Steping-through-in-F8.jpg
https://i.postimg.cc/XYxGkPYZ/Steping-through-in-F8.jpg
Steping through in F8.JPGSteping through in F8.jpgSteping through in F8.JPGSteping through in F8.JPG
Etc…
At each point, you can check if files and folders are being made, filled or killed , etc., as they should be
Alan




Reply With Quote
Bookmarks