Old workbook (once opened by VBA) keeps opening when I open another excel file -


i building database in access, import data excel workbook questionnaire. have coded import-sub selects, opens, retrieves data , closes workbook.

the problem this: reason, when open excel workbook on computer (at time when neither access or excel in use) old version of questionnaire keeps opening well. problem doesn't end restarting computer, deleting specific questionnaire-workbook. starts happening workbook.

i have theory might because - in import-sub - have opened questionnaire, encountered run-time error has ended sub before closed workbook, , somehow workbook still "open". or there still link active.

so have 2 questions:

1.) know how can fix problem?

2.) there consequences of not closing workbook open through vba?

my relevant code is:

dim myxl excel.application dim mywb excel.workbook ... 

in between lots of stuff happening, several times error occurs interrupts program.

... mywb.close false myxl.quit 

appreciate on this!

your theory likely. if never display excel application, errors encountered, , code never closes workbook left open in background , code lose reference it. next time open excel file instance of excel open(but hidden view) "picks up" request , opens file, displaying file still open macro.

1.) should set error handling workbook , excel application closed when there non-recoverable error.

sub mysub()     on error goto handle_err      <... code ...>      exit sub handle_err:     mywb.close false     myxl.quit end sub 

if have other error handling statements in code reset on error goto handle_err instead of goto 0 etc.

2.) consequences of not closing workbook obvious ones- system resources it's using and, if open editing, no 1 else can edit it.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -