Iamlaosong
folder inside the image file is saved with a single scan, the file name is the mail number, now want to collect these mail numbers, because the volume is very large, it is not possible to intercept a single, only through the program implementation, assuming that the current worksheet B is placed in the folder of these image files, The following program can be used to tell the message number of these image files:
Sub findname () Dim FS, F, F1, FC, Mydir MaxRow = Sheets ("Mail Number"). UsedRange.Rows.Count If maxrow >= 2 then Sheets ("Mail Number"). Rows ("2:" & MaxRow). Delete Shift:=xlup Lineno = [B65536]. End (Xlup). Row ' number of rows, number of folders Row1 = 2 for num = 6 to Lineno ' from line 6th to store folder name Mydir = Thisworkbook.path & "\" & Cells (num, 2) ' folder name if Dir (Mydir, vbdirectory) <> vbnullstring Then ' Dir function can not only determine whether a folder exists, You can also determine whether a file exists set fs = CreateObject ("Scripting.FileSystemObject") set F = fs. GetFolder (Mydir) ' Enter the directory you specified in parentheses Set FC = F.files for each F1 in FC Shee TS ("Mail number"). Cells (row1, 1) = Left (f1.name) Row1 = row1 + 1 Next cells (num, 3) = "Success" E LSE ' MsgBox Mydir & ' folder does not exist! ", vbOKOnly," Iamlaosong "Cells (num, 3) =" Failed "End If Next num MsgBox" Number of extracted mail numbers: "& Row1-2, vbOKOnly, "Iamlaosong" End Sub
"VBA Research" find the names of all the files under the folder