word 2016 vba not writing to protected excel workbook -
my task take forms (and accompanying spreadsheets) use on google docs(sheets), , transfer them our share drive. losing access google docs(sheets) (company change o365) , @ least have 1 of these things ready go lose access google docs. options limited. i'm not versed in creating pdf forms, our version of adobe isn't developers anyway. anyway, have built first form , accompanying protected spreadsheet (needed because have personal information). problem spreadsheet opening, closing without writing information. macros running without breaking in it's current form. code word document follows:
sub submitbutton_click() application.screenupdating = false dim exctransfer excel.application dim excwkbk workbook dim excsht worksheet set exctransfer = new excel.application set excwkbk = exctransfer.workbooks.open("l:\30 day short term_ storage\security\security forms\vehicle registration forms\vehicle_ registration worksheet.xlsm", readonly:=false, password:="********",_ writerespassword:="********") excwkbk.unprotect password:="********" set excsht = sheets("current 2016") excsht.activate dim irow long irow = excsht.cells.find(what:="*", searchorder:=xlrows,_ searchdirection:=xlprevious, lookin:=xlvalues).row + 1 excsht .cells(irow, 1) = me.namebox.value if addveh .cells(irow, 2) = "add vehicle" elseif remveh .cells(irow, 2) = "remove vehicle" else .cells(irow, 2) = "" end if if prmy .cells(irow, 3) = "yes" elseif prmn .cells(irow, 3) = "no" else .cells(irow, 3) = "" end if .cells(irow, 4) = me.vmake.value .cells(irow, 5) = me.vmodel.value .cells(irow, 6) = me.vcolor.value .cells(irow, 7) = me.vlicense.value end excwkbk.close savechanges = true exctransfer.quit me.namebox.value = "" me.addveh = false me.remveh = false me.prmy = false me.prmn = false me.vmake.value = "" me.vmodel.value = "" me.vcolor.value = "" me.vlicense.value = "" application.screenupdating = true application.quit savechanges:=true end sub
the code have spreadsheet follows:
sub workbook_open() thisworkbook.password = "********" end sub sub workbook_modify() thisworkbook.unprotect password:="********" end sub
i'm sure have more code needed, that's way work. missing? i'm sure it's 1 liner.
Comments
Post a Comment