Given: I recorded a simple macro in Openoffice to save my worksheet as a CSV file. Here it is.
sub toCSV
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///path/csv/filename.csv"
args1(1).Name = "FilterName"
args1(1).Value = "Text - txt - csv (StarCalc)"
args1(2).Name = "FilterOptions"
args1(2).Value = "59,34,76,1"
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args1())
end sub
Problem: I want to add some features to this function. 1. I need to get the current XLS filename so that I can put that at the end of my static path. So file:///path/csv/ is going to always remain the same, and filename.csv will be coming from filename.xls. 2. Well, I'll need to do some regex replacement on that filename-revision01.xls to ultimately get filename.csv.
I can do regex matching well, I'm simply looking for hints on string concatenation, how to get the current filename, and how to write a regex expression within a macro.
BTW, what is this language called!?