KlausW
Active Member
- Joined
- Sep 9, 2020
- Messages
- 390
- Office Version
- 2016
- Platform
- Windows
Hi
I have a challenge
I would like to protect a closed Excel Workbook, from an open Excel Workbook, where the name of the Workbook I would like to protect is in the sheet prisliste cell J4
I have tried this code but can't get it to work.
Some who can help
Any help will be appreciated
Best regards
Klaus W
I have a challenge
I would like to protect a closed Excel Workbook, from an open Excel Workbook, where the name of the Workbook I would like to protect is in the sheet prisliste cell J4
I have tried this code but can't get it to work.
Some who can help
Any help will be appreciated
Best regards
Klaus W
VBA Code:
Sub vba_protect_workbook()
'declare varibale to use for the workbook
Dim wb As Workbook
'open the workbook that you want to protect
Set wb = Workbooks.Open Range (“J4”)
'turn off the screen-updating to _
done everything in the backend
Application.ScreenUpdating = False
'protect the workbook
wb.Protect
'close the workbook after protecting
wb.Close savechanges = True 'turn off the screen-updating
Application.ScreenUpdating = True
End Sub