I wrote a Basic macro to calculate the Hash code of a given file name. It then pastes the hash code into the active cell of the document. This is my macro:
function GetHash(filename)
Dim myCommand as String
Dim fullCommand as String
myCommand = "/usr/bin/sha256sum " & filename
fullCommand="-c "" " & myCommand & " | xclip -selection clipboard"" "
MsgBox("bash " & fullCommand)
Shell ("bash", 1, fullCommand, true)
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
End function
I just call it with =GETHASH(C2)
My problem: If I execute this, it says that locked cells cannot be changed. However, neither the sheet nor the cell is protected. How can I have this paste the result of my shell call into the cell that is calling the macro?