vba - Runtime error 91: object variable or with block variable not set -


i'm running macro in word which, among other things, adds line bottom of table existing in document , fills cells. odd thing majority of documents works, there couple of documents receive run time error 91.

'update document properties, updates header, updates table of contents, ' , adds file version history table. sub zzaddversionhistory(strusuario string, strdescripcion string)     dim newdate string     dim rownumber integer     dim rownew row     dim strissue string     dim ascissue integer      'updates date property     newdate = format(date, "dd/mm/yyyy")     activedocument.customdocumentproperties("date").value = newdate      'finds version issue property , updates version     if docpropertyexists("issue") = true         strissue = activedocument.customdocumentproperties("issue").value         ascissue = (asc(strissue)) + 1 'convierte el issue en ascii y le suma uno         strissue = chr(ascissue)       'convierte el ascii en caracter         activedocument.customdocumentproperties("issue").value = strissue     end if      'updates header , footer     zzactualizarheaderfooter      'updates fields     zzactualizarcampos      'accepts changes in header y footer     zzacceptchangesinheaderfooter      'adds row table     rownumber = application.activedocument.tables(1).rows.count     set rownew = application.activedocument.tables(1).rows.add      'inserts ktc issue in first cell of new row     rownew.cells(1).range.insertafter (strissue) ''' runtime-error here     'inserts issued in third cell of new row     rownew.cells(3).range.insertafter (strusuario)     'inserts date in fourth cell of new row     rownew.cells(4).range.insertafter (newdate)     'inserts description of changes in fifth cell of new row     rownew.cells(5).range.insertafter (strdescripcion)      'updates table of contents     zzactualizarindices end sub 

if needed can provide subs , functions called macro, don't think have issue. believe problem somewhere in documents, in table format, not find explanation anywhere nor can find difference tables in other documents.

nested tables mess cells collection. once manually merge/split cells on last row , add new row, things become... different. save rtf, @ code, , scratch head.

use 1 (the first? second?) "standard" row count columns , adjust code in case column count / cells count of last row differs "norm". use "selection" , breakpoint investigate troublesome table learn how handle these special cases.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -