python - Identifying if a Cell contains an equation in Word -
i have table in word filled different texts, , equations using microsoft equation 3.0.
i trying read text table , create excel sheet same table.
is there way of normalizing equations in word text?
if not, know how can identify equation bypass it?
my current code reading table this:
word = win32.gencache.ensuredispatch('word.application') word.visible = false raw_files = glob('*.docx') xl = win32.gencache.ensuredispatch('excel.application') ss = xl.workbooks.add() f in raw_files: word.documents.open(f) doc = word.activedocument x in xrange(1, doc.paragraphs.count+1): otext = doc.paragraphs(x) if otext.range.tables.count >0 : ph = ss.activesheet r in xrange(1, otext.range.tables(1).rows.count): c in xrange(1, otext.range.tables(1).columns.count): if otext.range.tables(1).cell(r,c).range.text != none: ph.cells(r+2,c).value = otext.range.tables(1).cell(r,c).range.text
the error when run equation 'the requested member not exist.'
is there easy way bypass cell equation in it?
if running word 2010 (possibly 2007) check if there equation in cell in way (this complete loop each cell in table can convert needs, word-vba code, tried , tested word 2010):
dim eqcell cell each eqcell in activedocument.tables(1).range.cells if eqcell.range.omaths.count > 0 'if there equation if statement return true 'so, cell should bypassed '**edit** how row , column number of cell: dim rowno long dim colno long rowno = eqcell.range.information(wdendofrangerownumber) colno = eqcell.range.information(wdendofrangecolumnnumber) debug.print rowno, colno '**end of edit** end if next
you try normalize equation referring properties of omathfunction object. unfortunately, have no experience in area.
edit
to use solution within code implement in few possible ways:
a) check if there equation in table:
if otext.range.tables(1).range.omath.count > 0 ... '>>here
b) check if there equation in cell:
if otext.range.tables(1).cell(r,c).range.omath.count > 0 ... '>>here
Comments
Post a Comment