Disable macro execution while converting to a pdf

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
zmotiwala
Posts: 46
Joined: Wed Dec 28, 2011 5:34 pm

Disable macro execution while converting to a pdf

Post by zmotiwala »

We have a doc file with a date macro. We are trying to convert it to a pdf using java , open office and JOD.

When the document is opened in word it has a warning , PROTECTED VIEW Be careful - files from the Internet contain viruses.Unless you need to edit, it's safer to stay in Protected View. Enable Editing(Button). In this mode the date is a previous value that was generated. As soon as I hit Enable Editing it changes todays value.

Now the challenge , when this doc in its original state is converted to a pdf using open office the date shown is todays date.
If the file is natively opened in libre office, libre office complains that it has macros and that they are disabled , and displays the todays date.

Ideally I want the date displayed in microsoft word to be shown when the pdf is created using libre. Is there anyway this can be achieved, is there a way for libre to not run that macro by setting some property value and using JOD.
Last edited by robleyd on Thu Apr 25, 2019 4:34 am, edited 1 time in total.
Reason: Remove known issue icon
Libre Office 5.2.5
Windows
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Disable macro execution while converting to a pdf

Post by Zizi64 »

Please upload a sample file here.


Your signature is:
Open Office 3.0
Windows
Please update your signature in this forum
Forum header - Use Control Panel - Profile )TAB) - Edit signature (subTAB)
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Disable macro execution while converting to a pdf

Post by Villeroy »

1) If you are working with *.doc files you better use Microsoft products.
2) Do you know the difference between a date field and a fixed date field? The fixed one fixates the date when the file was stored for the first time. The shows the current date when the file was loaded.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
zmotiwala
Posts: 46
Joined: Wed Dec 28, 2011 5:34 pm

Re: Disable macro execution while converting to a pdf

Post by zmotiwala »

I cannot upload the sample file it contains sensitive data.
Libre Office 5.2.5
Windows
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Disable macro execution while converting to a pdf

Post by RoryOF »

Change the data so we can inspect the file.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
zmotiwala
Posts: 46
Joined: Wed Dec 28, 2011 5:34 pm

Re: Disable macro execution while converting to a pdf

Post by zmotiwala »

Villeroy wrote:1) If you are working with *.doc files you better use Microsoft products.
2) Do you know the difference between a date field and a fixed date field? The fixed one fixates the date when the file was stored for the first time. The shows the current date when the file was loaded.

No I do not the difference between the two. Did you mean the latter shows the current date when the file is loaded?
Libre Office 5.2.5
Windows
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Disable macro execution while converting to a pdf

Post by Villeroy »

The fixed one shows the creation time. Typically it's used with letter templates. You create a new file and when you save it under some name the date is fixed until you save it under some other name. The other variant of date field always shows the current date.
https://support.office.com/en-us/articl ... ca9f3beed1
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JeJe
Volunteer
Posts: 2763
Joined: Wed Mar 09, 2016 2:40 pm

Re: Disable macro execution while converting to a pdf

Post by JeJe »

You can stop an individual macro running in various ways such

Insert the line "Exit sub" or "Exit function" eg

Code: Select all

sub changeDate()
exit sub
blah blah  - won't run anymore

end sub 

or

function changeDate()
exit function

blah blah  - won't run anymore

end function 



or comment out the lines in the macro (or even the whole macro) that you don't want to run by putting a ' at the start of each

Code: Select all

sub changeDate()

'blah blah  - won't run anymore

end sub 

or comment out the whole function:

'function changeDate() 
'blah blah 
'end function 



Edit or you can use the exit sub or function with a condition. Something can be a boolean variable or anything else anywhere that resolves to true or false.

Code: Select all

dim something as boolean 

function changeDate()
if something = true then exit function

blah blah  - won't run anymore if something is true

end function 


Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply