Unprotect Excel sheet with Access VBA

I trying to unprotect an Excel sheet (UFMS_Budget_Trans) from Access and save and quit Excel after unprotecting. Any thoughts on how the code would look. Thanks
shieldscoAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Commented:
test this code

dim xlObj as Object, xlfile as string, pwd as string
pwd="yourpassword"
xlfile="C:\myExcel.xlsx"
set xlobj=createobject("excel.application")
      xlobj.workbooks.open xlfile
      with xlobj
            .activeworkbook.unprotect pwd
            .worksheets("UFMS_Budget_Trans").activate
            .worksheets("UFMS_Budget_Trans").unprotect pwd
            .activeworkbook.save
      end with
      xlobj.quit
0
 
shieldscoAuthor Commented:
No password
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.