segunda-feira, 9 de janeiro de 2012

Removing macro's from a LibreOffice/OpenOffice document

I had an OpenDocument Spreadsheet document that gave the security warning "This document contains macros. Execution of this macros is disabled due to the current macro security setting. Therefore, some functionality may not be available."
Since the document didn't need macro's, I investigated the macros, using the menu "Tools" => "Organize Macros" => "LibreOffice Basic". A "Basic" macro was present, but only contained whitespace.
For some reason, I was unable to remove the macro because the button "Delete" was disabled.
A workaround is to remove the macros programmatically, by creating a new macro.  In the window "LibreOffice Basic Macros", click the button "Edit". Add the code below:

Sub RemoveMacros
basicLibraries = ThisComponent.BasicLibraries
standard = basicLibraries.getByName( "Standard" )
standard.removeByName( "Module1" )
End Sub

Change the text "Module1" to the name of the Module that you want to delete. Run the code by pressing the key F5.
This code works on both LibreOffice and OpenOffice.

Nenhum comentário:

Postar um comentário