i have multiple word files. import them in such way name of file comes in cell a1 followed data in cells a2:a8 example. want next word file in folder import file name cell b2 , data in cells b2:b8.
the data in particular word file looks this:
z3cc07002466 zaic07000270 zrhc07003384 z9hc07000576 z8fc07002646 z6ec07000339 z6nc07000746
i want import multiple files 1 excel sheet each word file data next each other.
can vba enable me folder multiple docs inside it?
i suppose word documents have simple formal, sequence of lines. if words stored in word table, different story. create , execute macro:
sub fromworddocstomulticols() dim f string: f = "c:\so\" dim s string: s = dir(f & "*.docx") dim wdapp new word.application, wddoc word.document dim col integer: col = 1 on error goto errhandler until s = "" set wddoc = wdapp.documents.open(f & s) wddoc.range.copy sheet1.cells(1, col).value = s sheet1.cells(2, col).pastespecial xlpastevalues wddoc.close false: col = col + 1: s = dir loop errhandler: if err.number <> 0 msgbox err.description if not wdapp nothing wdapp.quit false end sub
Comments
Post a Comment