VBA Multiple Word Tables to Excel - No Tables in Document -


i exported of tables large word document few months ago, computer went , lost vba had used...note ++ decided disappear , take files it.

so, have looked several different options out there pull tables word file excel.

every 1 try says there no tables in word file. have tried multiple files, same thing.

the other change in environment upgraded windows 10.

i have racked brain , cannot figure out why not seeing tables?

i can copy tables different word file:

sub copytables() dim source document dim target document dim tbl table dim tr range  set source = activedocument set target = documents.add  each tbl in source.tables     set tr = target.range     tr.collapse wdcollapseend     tr.formattedtext = tbl.range.formattedtext     tr.collapse wdcollapseend     tr.text = vbcrlf next end sub 

and can find table number in word file:

sub findtablenumber() dim j integer dim itablenum integer dim otbl table  selection.bookmarks.add ("tempbm") j = 1 activedocument.tables.count     set otbl = activedocument.tables(j)     otbl.select     if selection.bookmarks.exists("tempbm")         itablenum = j         exit     end if next j activedocument.bookmarks("tempbm").select activedocument.bookmarks("tempbm").delete msgbox "the current table table " & itablenum end sub 

this example of vba have tried, , received no tables in document:

option explicit  sub importwordtable()  dim wddoc object dim wdfilename variant dim tableno integer 'table number in word dim irow long 'row index in excel dim icol integer 'column index in excel dim resultrow long dim tablestart integer dim tabletot integer  on error resume next  activesheet.range("a:az").clearcontents  wdfilename = application.getopenfilename("word files (*.docx),*.docx", , _ "browse file containing table imported")  if wdfilename = false exit sub '(user cancelled import file browser)  set wddoc = getobject(wdfilename) 'open word file  wddoc     tableno = wddoc.tables.count     tabletot = wddoc.tables.count     if tableno = 0         msgbox "this document contains no tables", _         vbexclamation, "import word table"     elseif tableno > 1         tableno = inputbox("this word document contains " & tableno & "     tables." & vbcrlf & _         "enter table start from", "import word table", "1")     end if      resultrow = 4      tablestart = 1 tabletot         .tables(tablestart)             'copy cell contents word table cells excel cells             irow = 1 .rows.count                 icol = 1 .columns.count                     cells(resultrow, icol) = worksheetfunction.clean(.cell    (irow, icol).range.text)                 next icol                 resultrow = resultrow + 1             next irow         end         resultrow = resultrow + 1     next tablestart end  end sub 


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -