Creating a macro - Writing a Script - Using the API


Postby Luc » Mon Feb 25, 2008 8:13 pm

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   Expand viewCollapse view
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("")

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 !
Posts: 2
Joined: Mon Feb 25, 2008 7:33 pm

Re: InsertSheetFromFile

Postby Villeroy » Mon Feb 25, 2008 9:07 pm

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: viewforum.php?f=20
This is the tool you need for Basic coding: ... _id=101416
This is the documentation and tools for compiled code (Java & C++):
This is the interface: ... heets.html
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Posts: 24784
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: InsertSheetFromFile

Postby acknak » Tue Feb 26, 2008 3:07 am

[Moved to Macros and UNO API]
AOO4/LO5 • Linux • Fedora 23
User avatar
Posts: 22738
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: InsertSheetFromFile

Postby Luc » Tue Feb 26, 2008 10:17 am

Thanks for your answers

Posts: 2
Joined: Mon Feb 25, 2008 7:33 pm

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests