Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Lock cell with macro

Hello! I would like to lock a cell in order to prevent that the user could write in, I use the command oCell.cellprotection.isLocked = True/False but don't run,

Can You help me?

Thank you

Have a nice day

Lock cell with macro

Hello! I would like to lock a cell in order to prevent that the user could write in, I use the command oCell.cellprotection.isLocked = True/False but don't run,

Can You help me?

Thank you

Have a nice day

P.S. I tried to use the command:

cp = createUnoStruct("com.sun.star.sheet.CellProtection") REM or: Dim cp as new com.sun.star.sheet.CellProtection

but nothing happens

Lock cell with macro

Hello! I would like to lock a cell in order to prevent that the user could write in, I use the command oCell.cellprotection.isLocked = True/False but don't run,

Can You help me?

Thank you

Have a nice day

P.S. I tried to use the command:

cp = createUnoStruct("com.sun.star.sheet.CellProtection") REM or: createUnoStruct("com.sun.star.sheet.CellProtection")

Dim cp as new com.sun.star.sheet.CellProtection

but nothing happens

Lock cell with macro

Hello! I would like to lock a cell in order to prevent that the user could write in, I use the command oCell.cellprotection.isLocked = True/False but don't run,

Can You help me?

Thank you

Have a nice day

P.S. I tried to use the command:

cp = createUnoStruct("com.sun.star.sheet.CellProtection")

Dim cp as new com.sun.star.sheet.CellProtection

but nothing happens

News: I don't undestand whi this code don't run:/

Sub test(pPass$, kj#)

oSheet = ThisComponent.getSheets().getbyname("Prova")
oSheet.UnProtect(pPass)
oCellRange = oSheet.GetcellRangebyname("Data")
oCell   = oCellRange.getCellByPosition(2,6)


select case kj

    case 1
        oCell.cellbackcolor = RGB(255,255,0)
        hh = oCell.CellProtection
        hh.IsLocked = False
        oCell.CellProtection = hh


    case 2
        oCell.clearContents(1)
        oCell.cellbackcolor = RGB(255,255,255)
        hh = oCell.CellProtection
        hh.IsLocked = True
        oCell.CellProtection = hh

end select

oSheet.Protect(pPass)

End Sub

Lock cell with macro

Hello! I would like to lock a cell in order to prevent that the user could write in, I use the command oCell.cellprotection.isLocked = True/False but don't run,

Can You help me?

Thank you

Have a nice day

P.S. I tried to use the command:

cp = createUnoStruct("com.sun.star.sheet.CellProtection")

Dim cp as new com.sun.star.sheet.CellProtection

but nothing happens

News: I don't undestand understand whi this code don't run:/run :/

Sub test(pPass$, kj#)

oSheet = ThisComponent.getSheets().getbyname("Prova")
oSheet.UnProtect(pPass)
oCellRange = oSheet.GetcellRangebyname("Data")
oCell   = oCellRange.getCellByPosition(2,6)


select case kj

    case 1
        oCell.cellbackcolor = RGB(255,255,0)
        hh = oCell.CellProtection
        hh.IsLocked = False
        oCell.CellProtection = hh


    case 2
        oCell.clearContents(1)
        oCell.cellbackcolor = RGB(255,255,255)
        hh = oCell.CellProtection
        hh.IsLocked = True
        oCell.CellProtection = hh

end select

oSheet.Protect(pPass)

End Sub

click to hide/show revision 6
None

updated 2018-09-25 11:35:32 +0100

Lupp gravatar image

Lock cell with macro

Hello! I would like to lock a cell in order to prevent that the user could write in, I use the command oCell.cellprotection.isLocked = True/False but don't run,

Can You help me?

Thank you

Have a nice day

P.S. I tried to use the command:

cp = createUnoStruct("com.sun.star.sheet.CellProtection")

Dim cp as new com.sun.star.sheet.CellProtection

but nothing happens

News: I don't understand whi this code don't run :/

Sub test(pPass$, kj#)

kj#)

oSheet = ThisComponent.getSheets().getbyname("Prova")
oSheet.UnProtect(pPass)
oCellRange = oSheet.GetcellRangebyname("Data")
oCell   = oCellRange.getCellByPosition(2,6)


select case kj

    case 1
        oCell.cellbackcolor = RGB(255,255,0)
        hh = oCell.CellProtection
        hh.IsLocked = False
        oCell.CellProtection = hh


    case 2
        oCell.clearContents(1)
        oCell.cellbackcolor = RGB(255,255,255)
        hh = oCell.CellProtection
        hh.IsLocked = True
        oCell.CellProtection = hh

end select

oSheet.Protect(pPass)

End Sub

End Sub