vba - Run-Time Error 91 doesn't make sense -
this run-time error 91 doesn't make sense me. issue didn't define something, i've noted time.
the error on line:
set f = thisapplication.activedocument.file
thisapplication defined towards beginning. file defined right before line.
here code:
option explicit public sub replacereference() dim invapp inventor.application set invapp = thisapplication dim namestr string dim newnamepath string dim namestr2 string dim oldnamepath string namestr = renamer.new_name.text 'concatenates full new file path newnamepath = renamer.path_text.text & "\" + namestr & "-" & right("00" & i, 3) & ".ipt" if err.number <> 0 msgbox "error found after newnamepath:" & err.description err.clear namestr2 = renamer.old_name_display.text 'concatenates old file name oldnamepath = namestr2 & "-" & right("00" & i, 3) & ".ipt" if err.number <> 0 msgbox "error found after oldnamepath:" & err.description err.clear while < 99 dim f file set f = thisapplication.activedocument.file dim fd filedescriptor each fd in f.referencedfiledescriptors if fd.fullfilename = oldnamepath fd.replacereference (newnamepath) end if next loop end sub
i know run-time error 91 common , seems silly, don't know wrong it.
could check this? can determine object nothing ... maybe activedocument in case?
if thisapplication nothing err.raise 91, , "thisapplication nothing!" else if thisapplication.activedocument nothing err.raise 91, , "activedocument nothing!" else if thisapplication.activedocument.file nothing err.raise 91, , "file nothing!" end if end if end if dim f file set f = thisapplication.activedocument.file
or (to reduce nesting of ifs):
if thisapplication nothing err.raise 91, , "thisapplication nothing!" end if if thisapplication.activedocument nothing err.raise 91, , "activedocument nothing!" end if if thisapplication.activedocument.file nothing err.raise 91, , "file nothing!" end if
Comments
Post a Comment