LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-23-2017, 02:35 PM   #1
mp100
Member
 
Registered: Sep 2015
Posts: 54

Rep: Reputation: Disabled
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
'
 
Old 06-23-2017, 02:59 PM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009
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.
 
Old 06-23-2017, 03:03 PM   #3
mp100
Member
 
Registered: Sep 2015
Posts: 54

Original Poster
Rep: Reputation: Disabled
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.
 
Old 06-23-2017, 06:01 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 17,495
Blog Entries: 28

Rep: Reputation: 5433Reputation: 5433Reputation: 5433Reputation: 5433Reputation: 5433Reputation: 5433Reputation: 5433Reputation: 5433Reputation: 5433Reputation: 5433Reputation: 5433
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.
 
Old 06-23-2017, 08:37 PM   #5
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009
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.
 
Old 06-24-2017, 03:03 AM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,655
Blog Entries: 3

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
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.
 
Old 06-24-2017, 11:02 AM   #7
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 5,788

Rep: Reputation: 2140Reputation: 2140Reputation: 2140Reputation: 2140Reputation: 2140Reputation: 2140Reputation: 2140Reputation: 2140Reputation: 2140Reputation: 2140Reputation: 2140
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.
 
Old 06-27-2017, 05:41 AM   #8
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 945

Rep: Reputation: 216Reputation: 216Reputation: 216
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

Last edited by AnanthaP; 06-27-2017 at 06:00 AM.
 
Old 06-27-2017, 01:51 PM   #9
mp100
Member
 
Registered: Sep 2015
Posts: 54

Original Poster
Rep: Reputation: Disabled
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] libre office writer cannot open older file drmjh Linux - General 1 05-05-2013 02:51 PM
[SOLVED] where are macros stored in libre office calc 3.6.2+ knobby67 Linux - Software 3 04-25-2013 11:28 PM
Problems in making Linpeople out of Winpeople (Libre Office macros) resetreset Linux - Software 1 11-04-2012 08:27 AM
Libre office writer has canceled the contents of a file without asking it Bianchina Linux - Newbie 2 05-04-2012 08:40 PM
MS office macros in Linux sailu_mvn Linux - Software 7 02-10-2006 09:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration