excel - Save As and disable formulas and macros -


i want make vba code save in map , turn off formulas , macros.

this i've come far isn't working.

sub opslaanzonderformules()   dim strfilename variant, strpath string   dim vbproj vbide.vbproject, vbcomp vbide.vbcomponent, codemod vbide.codemodule   strfilename = application.getsaveasfilename(initialfilename:=strpath & [aj2], _                                               filefilter:="excel files (*.xls), *.xls, excel 2007 files (*.xlsm), *.xslm", _                                               filterindex:=1, _                                               title:="kies de juiste map en pas eventueel de bestandsnaam aan!")   if strfilename = false     msgbox "oh oh... je hebt niet opgeslagen! "   else     activesheet.copy     activeworkbook         .sheets("blad1")             .unprotect             .usedrange.value = .usedrange.value             .protect         end      set vbproj = .vbproject      each vbcomp in vbproj.vbcomponents             if vbcomp.type = vbext_ct_document                 set codemod = vbcomp.codemodule                 codemod                     .deletelines 1, .countoflines                 end             else                 vbproj.vbcomponents.remove vbcomp             end if         next vbcomp     .saveas filename:=strfilename end   msgbox "gelukt!  opgeslagen als: " & strfilename    end if end sub 

if save file xlsx code automatcially removed. simplifies to:

sub opslaanzonderformules()   dim strfilename variant, strpath string   dim vbproj vbide.vbproject, vbcomp vbide.vbcomponent, codemod vbide.codemodule   strfilename = application.getsaveasfilename(initialfilename:=strpath & [aj2], _                                               filefilter:="excel files (*.xls), *.xls, excel 2007 files (*.xlsm), *.xslm", _                                               filterindex:=1, _                                               title:="kies de juiste map en pas eventueel de bestandsnaam aan!")   if strfilename = false       msgbox "oh oh... je hebt niet opgeslagen! "   else       activesheet.copy       activeworkbook             .sheets(1)                .unprotect                .usedrange.value = .usedrange.value                .protect             end       .saveas left$(strfilename, instrrev(strfilename, ".")) & "xlsx", xlopenxmlworkbook       end   msgbox "gelukt!  opgeslagen als: " & left$(strfilename, instrrev(strfilename, ".")) & "xlsx"   end if end sub