Page 1 of 1

Using MRI

PostPosted: Wed Jan 15, 2014 12:26 pm
by mike phillips
Having been urged to use MRI I need some help with this please!

If I use MRI <-Selection on a highlighted part of code I get a box simply saying 'void'

If I write this code
Code: Select all   Expand viewCollapse view
REM  *****  BASIC  *****

Option Explicit

Global oMRI As Object

sub Main
  Globalscope.BasicLibraries.LoadLibrary("MRILib")
  oMRI = CreateUnoService("mytools.Mri")
  oMRI.inspect(CellProtection)
end sub


it tells me the variable is not set.

Help please?

Re: Using MRI

PostPosted: Wed Jan 15, 2014 12:32 pm
by RPG
Hello

Read the help file about: option explicit
And the variable does not have value.

Romke

Re: Using MRI

PostPosted: Wed Jan 15, 2014 12:52 pm
by Villeroy
That macro has been written already. See "MyMacros".MRILib>Module1.Mri
It takes an optional argument which is the object you want to inspect. If that object is missing, Mri will inspect the StarDesktop variable (the collection of all frames).

Code: Select all   Expand viewCollapse view
GlobalScope.BasicLibraries.loadLibrary("MRILib")
sh = ThisComponent.Sheets.getByIndex(0)
cell = sh.getCellByPosition(0,0)
CellProtection = cell.CellProtection
MRILib.Module1.Mri(CellProtection)

But with MRI you don't need any additional code. Just select some cell(s) and call Tools>Add-ons>MRI(selection). Then double-click the line starting with "CellProtection".

Re: Using MRI

PostPosted: Wed Jan 15, 2014 7:16 pm
by mike phillips
Thank you, Villeroy. Great help.

It appears that Cell protection does not offer any way of recognising the original protection set up on the sheet - it was set to allow access to unlocked cells only. After running
Code: Select all   Expand viewCollapse view
Sheet.setPropertyValue( "CellProtection", tUnProtect )
Sheet.Protect("")

it appears to lock ALL cells. Is there a way to 'honour' the original protection criteria?