I have a basic macro that processes a document that is opened in OpenOffice. But I have to process tens of thousands of documents. Can anyone point me to a script that opens each file in a directory, runs a macro and saves the file in another directory.
Thanks,
Harry Spier
[Solved] Applying a macro to all files in a directory
-
- Posts: 21
- Joined: Fri Feb 01, 2013 9:24 pm
[Solved] Applying a macro to all files in a directory
Last edited by harryspier on Sat Nov 29, 2014 10:27 pm, edited 1 time in total.
OpenOffice 3.4.1 Windows 8
Re: Applying a macro to all files in a directory
Here is a rough version. I check if the file name ends in ods because my desktop has all kinds of files.
Code: Select all
directory = "C:\Users\fjcc\Desktop\"
newDirectory = "C:\Users\fjcc\Desktop\TargetFolder\"
file = DIR(directory)
While file <> ""
If RIGHT(file,3) = "ods" Then
fileURL = convertToURL(directory & file)
oDoc = StarDesktop.loadComponentFromURL(FileURL, "_blank", 0, Array())
'do stuff here
oDoc.storeAsURL(convertToURL(newDirectory & file), Array())
oDoc.close(TRUE)
End If
file = DIR()
WEnd
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
-
- Posts: 21
- Joined: Fri Feb 01, 2013 9:24 pm
Re: Applying a macro to all files in a directory
Thank you for this. That should get me going.
Regards,
Harry
Regards,
Harry
OpenOffice 3.4.1 Windows 8