excel - Error when setting workbook variable - 2147352565 -


i have simple code runs upon initialization of userform sets few workbook , worksheet variables can used throughout rest of modules, , references can changed in 1 place if file moves. migrated workbooks desktop separate server/drive, , accordingly updated file pathways; however, when try run code message:

"run-time error '-2147352565 (8002000b)': can't move focus control because invisible, not enabled, or of type not accept focus."

this error occurs on line

set reportwkbk = workbooks("n:\ rest of file pathway here\quart_template.xlsm") 

is there can happening on server/drive causing issue? if so, there can fix it? work other excel workbooks saved in same location seem have no issue being referenced, though references in workbook itself, not through visual basic.

the subscript out of range error occurs because excel workbook being referenced not open (or opening) in the same instance of excel. can reproduce error creating 2 workbooks (name 1 workbook2.xlsx) , ensuring open in separate instances of excel. run code:

sub openwkbknames()     dim wbk workbook     each wbk in workbooks         debug.print wbk.name     next     'hmm. workbook 2 not listed, lets activate , see happens.     workbooks("workbook2.xlsx").activate end sub 

you avoid issue looping through names of workbooks open in this instance of excel ensure available.

i've been researching run-time error '-2147352565 (8002000b)' , found this: https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.vsconstants.disp_e_badindex.aspx

apparently, vs's way of saying subscript out of range too. suspect (but have no solid proof) since code worked locally issue appeared after file migrated shared drive windows taking long time open file opens in new instance of excel. essentially, excel gets impatient , decides move on while windows completes task. base assumption on detection logic added excel 2013 (https://blogs.office.com/2013/06/03/opening-workbooks-by-running-separate-instances-of-excel/).


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -