InsertSheetFromFile

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Luc
Posts: 2
Joined: Mon Feb 25, 2008 7:33 pm

InsertSheetFromFile

Post by Luc »

Hi all,

I have many csv file that I would like to add as a sheet in a calc document.
Doing manual insert file from file work fine. So I would like to make this action with a macro.

Recording it I have :

Code: Select all

sub InsertSheetFromFile
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:InsertSheetFromFile", "", 0, Array())
end sub
I've noted that the "executeDispatch is commented out. Uncommenting just raise the dialog box whituout the selections I've done during macro recording.
After many research on the net I had a lot of code that looks to be outdated, not working at all, etc...
My current understantding is that I should create an Array() containing parameters for the ".uno:InsertSheetFromFile".
Unfortunately I was not able to find any documentations about those parameters.

My config is Linux Debian / OOo 2.3.1

Could someone help me ?

Ideally, I would like the macro to start by a FileSelection dialog allowing to select mutiple csv files and then insert one sheet per selected file...

thanks you for your answers !
Luc
User avatar
Villeroy
Volunteer
Posts: 31264
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: InsertSheetFromFile

Post by Villeroy »

Why do you want to spoil your document with unnecessary Basic code when insertion of sheets is so easy? You won't ever save the time you wasted for this macro. How many sheets do you insert per day, per hour, per minute? No, macros are *not* an elegant solution in general and they do *not* prove a higher level of expertise nor proficiency.

btw: This is the wrong forum for your request anyway.
This is the forum: http://user.services.openoffice.org/en/ ... m.php?f=20
This is the tool you need for Basic coding: http://sourceforge.net/project/showfile ... _id=101416
This is the documentation and tools for compiled code (Java & C++): http://download.openoffice.org/sdk.html
This is the interface: http://api.openoffice.org/docs/common/r ... heets.html
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: InsertSheetFromFile

Post by acknak »

[Moved to Macros and UNO API]
AOO4/LO5 • Linux • Fedora 23
Luc
Posts: 2
Joined: Mon Feb 25, 2008 7:33 pm

Re: InsertSheetFromFile

Post by Luc »

Thanks for your answers

regards
Luc
Post Reply