Results 1 to 2 of 2

Thread: Get Pictures from a Word Document ( in All Sub Folders produced?? )

  1. #1
    Junior Member
    Join Date
    Aug 2021
    Posts
    13
    Rep Power
    0

    Get Pictures from a Word Document ( in All Sub Folders produced?? )

    Dear All,

    I am using Office 2013.

    I have a folder with many sub folders having word and excel files.

    Excel file does not have images but the word documents under each sub folder have many images which I would like to move under each respective folders.

    I found this code on the group which used to work but now it is giving run time error '53': File not found and highlights the following:

    Kill strPath & "" & strDocumentName & ".htm*"

    It used to work and move the images to a folder “MovedToHere”.

    Code:
    Sub GetPicturesFromWordDocument()
    
        Dim strFile As String
        Dim strFileType As String
        Dim strPath As String
        Dim lngLoop As Long
        Dim strOriginalFile As String
        Dim strDocumentName As String
        strOriginalFile = ActiveDocument.FullName
        strDocumentName = Left(ActiveDocument.Name, InStrRev(ActiveDocument.Name, ".") - 1)
        strPath = ActiveDocument.Path
        ActiveDocument.SaveAs strPath & "\" & strDocumentName, wdFormatHTML, , , , , True
        strFileType = "*.png;*.jpeg;*.jpg;*.bmp" 'Split with semi-colon if you want to specify more file types.
         
        MkDir strPath & "\MovedToHere"
        For lngLoop = LBound(Split(strFileType, ";")) To UBound(Split(strFileType, ";"))
            strFile = Dir(strPath & "\" & strDocumentName & "_files\" & Split(strFileType, ";")(lngLoop))
            Do While strFile <> ""
                Name strPath & "\" & strDocumentName & "_files\" & strFile As strPath & "\MovedToHere\" & "New " & strFile
                strFile = Dir
            Loop
        Next lngLoop
        ActiveDocument.Close 0
        Documents.Open strOriginalFile
        Kill strPath & "\" & strDocumentName & ".htm*"
        Kill strPath & "\" & strDocumentName & "_files\*.*"
        RmDir strPath & "\" & strDocumentName & "_files"
        strFile = vbNullString
        strFileType = vbNullString
        strPath = vbNullString
        lngLoop = Empty
         
    End Sub
    I want to fix this code and also amend to run on all the sub folders.
    Can someone fix this issue for me please.
    Thanks in advance

  2. #2
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,468
    Rep Power
    10
    see here:
    https://excelfox.com/forum/showthrea...ll=1#post15615


    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGADdPM65i9PG
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGADdPQHFk_zm
    http://www.eileenslounge.com/viewtopic.php?p=324457#p324457
    http://www.eileenslounge.com/viewtopic.php?p=324064#p324064
    http://www.eileenslounge.com/viewtopic.php?p=323960#p323960
    https://www.youtube.com/watch?v=7VwD9KuyMk4&lc=UgyZCnNfnZRfgwzDlQF4AaABAg
    https://www.youtube.com/watch?v=7VwD9KuyMk4&lc=UgyZCnNfnZRfgwzDlQF4AaABAg. ADd4m2zp_xDADd6Nnotj1C
    s://www.youtube.com/watch?v=7VwD9KuyMk4&lc=UgySdtXqcaA27wQLd1t4AaABAg
    http://www.eileenslounge.com/viewtopic.php?p=323959#p323959
    http://www.eileenslounge.com/viewtopic.php?f=30&t=41784
    http://www.eileenslounge.com/viewtopic.php?p=323966#p323966
    http://www.eileenslounge.com/viewtopic.php?p=323959#p323959
    http://www.eileenslounge.com/viewtopic.php?p=323960#p323960
    http://www.eileenslounge.com/viewtopic.php?p=323894#p323894
    http://www.eileenslounge.com/viewtopic.php?p=323843#p323843
    https://www.youtube.com/watch?v=fEHKPhJxgBA&lc=Ugxx8_MjhC9FDaQgcHN4AaABAg
    https://www.youtube.com/watch?v=jpjYm4UvyWk&lc=Ugx_Qd4rfAN_ZYcJbo94AaABAg. ACGbG9c76OWACGbjKa7H8k
    https://www.youtube.com/watch?v=jpjYm4UvyWk&lc=Ugx_Qd4rfAN_ZYcJbo94AaABAg
    https://www.youtube.com/watch?v=GyPHaydeng0&lc=UgzE4a4f_e_y9Rk5OR94AaABAg
    https://www.youtube.com/watch?v=I5FkNG94BcQ&lc=UgxXnkEHqulXSR5tXwh4AaABAg
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa6BSa173Z
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa6-64Xpgl
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa5ms39yjd
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa5ZXJwRCM
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa4Pr15NUt
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa4I83JelY
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGADdMo2n-hyF
    https://www.youtube.com/watch?v=C43btudYyzA&lc=Ugyf349Ue6_4umFfNUB4AaABAg. 8mjgPNoTt_HABa3tnAjhZU
    http://www.eileenslounge.com/viewtopic.php?p=323547#p323547
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 01-23-2025 at 07:05 PM.

Similar Threads

  1. Get Pictures from Word Documents in All Sub Folders
    By prkhan56 in forum Excel Help
    Replies: 23
    Last Post: 10-06-2021, 01:17 PM
  2. Replies: 0
    Last Post: 02-23-2017, 11:42 PM
  3. Macro To Connect Word Document To Excel Not Working
    By fjeldgaard in forum Word Help
    Replies: 1
    Last Post: 08-29-2014, 08:31 AM
  4. Loop_Find & Copy to word document
    By Excelfun in forum Excel Help
    Replies: 3
    Last Post: 01-14-2014, 10:11 PM
  5. Send Outlook Email With Word Document
    By Murali K in forum Excel Help
    Replies: 2
    Last Post: 06-27-2012, 08:42 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
  •