excel - workbook_beforesave event not firing -


i have vba code forced save dialog box show default save type xlsm while trying save xltm. please check out attached code , correct me if code incorrect

application.enableevents = false  application.displayalerts = false  if saveasui = true      binprocess = true  'the following statements shows save dialog box default path     set filesavename = application.filedialog(msofiledialogsaveas)     filesavename.initialfilename = thisworkbook.name     filesavename.filterindex = 2   'select save ".xlsm" extension     filesavename.title = "save as"     intchoice = filesavename.show     if intchoice = 0     else         filesavename.execute     end if else 'normal save      binprocess = true      cancel = true     thisworkbook.save  end if application.enableevents = true application.displayalerts = true 

the above code works fine while trying save using (ctrl+s). if tried close through excel close window option. excel shows default save-as pop-up. if click "save" option save pop-up , workbook_beforesave event not invoked(save dialog shown default data type changed xls xlsm). don't know mistake made? please me rid of this..

thanks in advance!!!

you need place code between these lines

private sub workbook_beforeclose(cancel boolean)  end sub 

Comments