Results 1 to 10 of 24

Thread: Get Pictures from Word Documents in All Sub Folders

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    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
    Code:
        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 <> ""
    As it loops you will see the folder MovedToHere being filled
    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
    Last edited by DocAElstein; 09-22-2021 at 03:44 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    KILL A MODERATOR!!

Similar Threads

  1. Replies: 1
    Last Post: 08-26-2021, 11:42 AM
  2. Replies: 3
    Last Post: 07-09-2020, 02:17 AM
  3. Replies: 7
    Last Post: 08-24-2015, 10:58 PM
  4. Replies: 9
    Last Post: 07-26-2013, 02:34 PM
  5. Replies: 1
    Last Post: 10-16-2012, 01:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •