Link to home
Start Free TrialLog in
Avatar of leekf
leekf

asked on

vb code to protect excel worksheet

how to protect excel work sheet with visual basic?

the macro code of protection is:
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

how to transform it to visual basic code?

PS: I open excel with the following code:

    Set objExcel = GetObject(Source)
    objExcel.Application.Visible = True
    objExcel.windows(1).Visible = True
    objExcel.sheets(1).cells(1, 1).Value = "hihi"

........ after that I want to protect the workbook



Thanks
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

objExcel.sheets(1).Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

?
Avatar of leekf
leekf

ASKER

thanks

but i cannot set the password to protect

Could you tell me how to do that?
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial