Deleting MACRO from DOC/DOCX/ODT File

Java, C++, C#, Delphi, ??? - Using the UNO bridges

Deleting MACRO from DOC/DOCX/ODT File

Postby sachin.shinde » Fri Jul 21, 2017 2:14 pm

Hi All,

I am trying to Deleting MACRO from DOC/DOCX/ODT File using Open office SDK 4.1.3 using C# library, I not able to find any guidance,
can you please provide any pointers regarding.

Thanks,
Sachin S
OpenOffice 4.1.3 Windows 10
sachin.shinde
 
Posts: 4
Joined: Fri Jul 21, 2017 2:02 pm

Re: Deleting MACRO from DOC/DOCX/ODT File

Postby RoryOF » Fri Jul 21, 2017 2:22 pm

/Tools/ Options/ Organise Macros, select the language in which the macro was written (try all in turn if not certain), select the macros and press the Delete button on the macro organise window.
Apache OpenOffice 4.1.6 on Xubuntu 18.04 (mostly 64 bit version) and infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 27646
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Deleting MACRO from DOC/DOCX/ODT File

Postby sachin.shinde » Fri Jul 21, 2017 2:28 pm

Thanks RoryOF,

I am trying to do it pragmatically, can you please help.

Thanks
Sachin
OpenOffice 4.1.3 Windows 10
sachin.shinde
 
Posts: 4
Joined: Fri Jul 21, 2017 2:02 pm

Re: Deleting MACRO from DOC/DOCX/ODT File

Postby Villeroy » Fri Jul 21, 2017 3:48 pm

Code: Select all   Expand viewCollapse view
libs = ThisComponent.BasicLibraries
for each s in libs.getElementNames()
   libs.removeLibrary(s)
next
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 25952
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Deleting MACRO from DOC/DOCX/ODT File

Postby sachin.shinde » Mon Jul 24, 2017 8:27 am

Thanks Villeroy,

can please help me to with C# code.

Thanks,
Sachin
OpenOffice 4.1.3 Windows 10
sachin.shinde
 
Posts: 4
Joined: Fri Jul 21, 2017 2:02 pm

Re: Deleting MACRO from DOC/DOCX/ODT File

Postby Villeroy » Mon Jul 24, 2017 11:42 am

You are the C# developer. I don't even have a Windows machine. You should know how to connect with a running instance of your office suite and get a reference to a document. In my macro code "ThisComponent" refers to the currently active document.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 25952
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Deleting MACRO from DOC/DOCX/ODT File

Postby sachin.shinde » Mon Jul 24, 2017 12:09 pm

I have checked in code for "Document", it does not have any method "BasicLibraries" in C# assemblies/DLLs. I got, its hard get answers here for C# related queries for OPenOffice SDK.

Thanks for your time.
OpenOffice 4.1.3 Windows 10
sachin.shinde
 
Posts: 4
Joined: Fri Jul 21, 2017 2:02 pm

Re: Deleting MACRO from DOC/DOCX/ODT File

Postby Villeroy » Mon Jul 24, 2017 3:39 pm

[Tutorial] Introduction into object inspection with MRI
Install MRI. It produced the following code for me:
Code: Select all   Expand viewCollapse view
using System;
using unoidl.com.sun.star.beans;
using unoidl.com.sun.star.container;
using unoidl.com.sun.star.lang;
using unoidl.com.sun.star.script;
using unoidl.com.sun.star.uno;

public class Snippet {
public void snippet(XComponentContext xContext, object oInitialTarget)
{
   try
   {
      XPropertySet xPropSet = (XPropertySet)oInitialTarget;
      XLibraryContainer xLibraryContainer = (XLibraryContainer) xPropSet.getPropertyValue("BasicLibraries").Value;
      
      XNameAccess xNameAccess = (XNameAccess) xLibraryContainer;
      XNameAccess xNameAccess_2 = (XNameAccess) xNameAccess.getByName("Standard").Value;
   }
   catch (RuntimeException e)
   {
      // getByName
      Console.WriteLine(e.Message);
   }
   catch (WrappedTargetException e)
   {
      // getPropertyValue, getByName
      Console.WriteLine(e.Message);
   }
   catch (UnknownPropertyException e)
   {
      // getPropertyValue
      Console.WriteLine(e.Message);
   }
   catch (NoSuchElementException e)
   {
      // getByName
      Console.WriteLine(e.Message);
   }
}
}[

object oInitialTarget is the document in question
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 25952
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests