Hola jorge : )
On Sat, 27 Aug 2016 05:47:09 +0000, jorge escribió:
Good evening:
' Afternoon.
I'm also interested in importing .txt files into a spreadsheet adequately.
I try to make a macro in Calc to insert a sheet from a file in .txt
format or .csv using the LO process: Record macro.
Mm. A question: are you trying to make a macro because you plan to be
importing a file regularly or is it just a one-time import?
Or are you trying to import it as an exercise on how to make macros?
I did it but the macro run and stop in the directory where the file is,
but not record the select and not open the sheet although I did when I
recorded the macro.
I notice that you call your .csv file a "sheet" and I think it is not
a sheet, yet, but a text file.
The code that the process wrotten is this, would you please guide me to
finish:
I'm afraid I am not that familiar yet with macros, but it seems to me that
at some point the macro will ask you to select which file to import, right?
That is, a dilague window will appear to let you choose the kind of import
(separators, ...) ... Wait, I cannot find an "Import" option in
menus. : ! ?
Let's see:
REM ***** BASIC *****
sub Main
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
There, at the end you have a ".uno:InsertSheetFromFile"
¿How did you manage to "import" a file into your worksheet? I've only
managed it _opening_ a new file which is a .cvs file. And then the import
dialogue appears, I choose the options and the .csv file is correctly
imported into a worksheet.
As I say I'm not familiar with macros and don't know how that is done. But
It seems to me that perhaps you have to open a file instead of trying to
import it : ?
I hope someone who already does what you want illustrates us on what is to
be done and how.
I use LibreOffice version 4.2.8.2 on Ubuntu 14.04 LTS
I'm using LO Versión: 4.3.3.2 on Debian GNU/Linux 8.5.
Felipe : )