LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Libre Office macros and Linux file systems (https://www.linuxquestions.org/questions/linux-newbie-8/libre-office-macros-and-linux-file-systems-4175608485/)

mp100 06-23-2017 02:35 PM

Libre Office macros and Linux file systems
 
Hello

I have just started on the fascinating journey with Linux (Mint in my case). One of the things I currently do on Windows is to automate various tasks in Word, using macros. One simple one is to make instant backups from an icon on the toolbar. I'm sure I'll be able to nut out making the icon. My question is can I use more or less the same VBA coding on the Macro? Currently I save a copy of the open word file to another drive when I click on the icon. Thus I can keep backups as often as I like while writing (every page, paragraph, sentence or even word!). I'd like to this in Linux too. This is a fragment showing how I currently do it in VBA/Word

strBackupPath = "F:\AAMiscBackupFiles" 'USB Stick
Set oDoc=ActiveDocument
With oDoc
'mark the current cursor position
.Bookmarks.Add Range:=Selection.Range, Name:="OpenAt"
.Save ' to the basic location (main 'hard' disk/SSD)
strFileA = .FullName
strFileB = strBackupPath & aComment & .Name
.Close 'Close the document prior to copying
End With
FileCopy strFileA, strFileB 'copy document
Documents.Open strFileA 'return to document
ActiveWindow.View.Type = wdPrintView
ActiveDocument.Bookmarks("OpenAt").Select 'cursor posn
'

AwesomeMachine 06-23-2017 02:59 PM

I would suggest the "save as" icon. After you do save as, then you can just the "save" icon, and it will keep saving it to the same place.

I'm pretty sure the LibreOffice macro language is not directly compatible with vb.

mp100 06-23-2017 03:03 PM

Thanks. The problem is that I currently save to multiple places: a USB stick, an outboard hard drive, the Cloud and the main drive, all with one click. I have written other macros such as one to take a Word document, make changes to it and its title and save it as PDF. That will be a harder one to crack no doubt, but it must be possible. I thought I'd start with the simple one! One of the things is of course the different file tree.

frankbell 06-23-2017 06:01 PM

Quote:

I'm pretty sure the LibreOffice macro language is not directly compatible with vb.
AwesomeMachine is quite correct. Visual Basic is quite specifically Windows thing.

AwesomeMachine 06-23-2017 08:37 PM

I guess you want to be quite careful not to lose any work. That's understandable. I'm simply not sure whether or not LibreOffice can use an actual programming language for macros, or if it is only the LibreOffice macro language.

I have found there is always a way. It might be different than what you are used to. But it also might be better! I did find one user who programmed a macro to convert a document and save it to a remote location in the new format, all with one click.

You mentioned that. So, I thought I'd mention that it is possible. The user didn't cite any examples.

Turbocapitalist 06-24-2017 03:03 AM

You can write LibreOffice macros in Java, ECMAscript, or Python. There are a few guides around for that. You'll have to look around to find ones that are useful to you.

As an aside, yours is the first use case that makes sense for a macro that I have seen since ages and ages. Interesting idea.

As for M$ Visual Basic, it is unsupported.

DavidMcCann 06-24-2017 11:02 AM

You need the documentation!
https://www.libreoffice.org/get-help/documentation/
The Getting Started volume has details of macros.

Don't forget that Writer can do automatic saving: you can configure it from the menu: Tools - Options - Load/Save - General. The details are explained in the Writer documentation.

AnanthaP 06-27-2017 05:41 AM

Libre office says some macros will work if you set Tools -->> Options -->> Load/Save -->> VBA properties Never tried it though.

You should let the system take care of replicating to other locations maybe by simply having "link"ed the saved file initially.

OK

mp100 06-27-2017 01:51 PM

Thanks all. Have made considerable progress but have hit a snag. This is a fragment of code written in a macro, and *it works*:

FileN = GetFileNameWithoutExtension(oDocURL)
FileNN = FileN + ".doc"
SaveURL = ConvertToURL(FileNN)
sMyPath = home
sFileName = GetFileNameWithoutExtension(oDoc.url)
sURL = ConvertToURL(sMyPath & sFileName)
ThisComponent.storeAsURL(sURL, array())

I repeat, it works. Now if I change the line that defines MyPath from home to suit the apparent path to a USB key I have, it does not work. The path to this appears to be media/alan/USBKEY/backup

I confirm that the USB key is called USBKEY and within it I have mkdired a dir called backup, both verified by looking at the path.

I would appreciate comments on what is wrong with my alternative path


All times are GMT -5. The time now is 02:55 PM.