Workbook with Ribbon keeps crashing Excel -



Workbook with Ribbon keeps crashing Excel -

i have big workbook complex vba project.

the workbook has custom-ribbon...

there quite alot happening in workbook_open event too, unprotecting , reprotecting (userinterfaceonly), hiding , showing various sheets, storing reference ribbon etc.

when macros not automatically enabled, workbook opens, enable button appears , when click happens should.

the problem arises when file trusted, , macros run automatically. in these circumstances, has tendency crash application.

it's though, if there pause user has click button, excel preparations, displays ribbon , workbook_open stuff, if there no enable button somehow excel's own startup stuff , displaying ribbon seems tangled workbook_open event, causing crash.

this happens in 2007, 2010 , 2013 , on both windows 7 & 8(.1)

i suspect ribbon, because problem isn’t total crash, instead, workbook opens, ribbon area blank.

fyi code in workbook_open event looks this:

enter code here private sub workbook_open() dim newhour single dim newminute single dim newsecond single dim waittime date application.screenupdating = false ' activate ribbon in v2007 application.sendkeys "%q{return}" phone call resetthesheets splash.visible = xlsheetvisible splash.protect shthidden.range("iword") phone call showhidesplash execsumm.visible = xlsheetvisible getstarted.visible = xlsheetvisible ' @ properties in prop sheet see should displayed if prop.range("prophidegetstarted") on error resume next execsumm .activate 'range("c4").select .unprotect password:=shthidden.[iword] .visible = xlsheetvisible .range("a1:a" & .range("lastrowcol").row).entirerow.hidden = false .range(.cells(1, 1), .cells(1, .range("lastrowcol").column)).entirecolumn.hidden = false ' check see if template column has in if worksheetfunction.counta(.range("templatecol")) = 0 .range("templatecol").entirecolumn.hidden = true ' check see if prior year should hidden if not prop.range("propbfbalances") .range("pptitle").entirecolumn.hidden = true .activate end else getstarted.select end if activewindow.scrollrow = 1 formshow: err.clear on error goto formshow frmsplash.show msofalse shthidden.range("ibalance") = "true" ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '' schedule start avoid 'startup-crashes' - didn't work way prevent ' newhour = hour(now()) ' newminute = minute(now()) ' newsecond = second(now()) + 1 ' waittime = timeserial(newhour, newminute, newsecond) ' application.wait waittime ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ err.clear on error goto 0 application.ontime + timevalue("00:00:01"), "startupmacro" end sub

you may try:

a. allow excel wait predefined time ready before or after sendkey thing per need:

application.wait(now + #0:00:05#) '5 sec illustration

courtesy: link

b. using msgbox popup (similar macro enable button) inhibit quick execution of rest of code.

excel excel-vba

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -