Disable macro execution while converting to a pdf

Creating a macro - Writing a Script - Using the API

Disable macro execution while converting to a pdf

Postby zmotiwala » Thu Apr 25, 2019 3:33 am

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
zmotiwala
 
Posts: 40
Joined: Wed Dec 28, 2011 5:34 pm

Re: Disable macro execution while converting to a pdf

Postby Zizi64 » Thu Apr 25, 2019 6:18 am

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; LO4.4.7, LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.4; AOO4.1.5
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
Zizi64
Volunteer
 
Posts: 7974
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Disable macro execution while converting to a pdf

Postby Villeroy » Thu Apr 25, 2019 12:02 pm

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, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26734
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Disable macro execution while converting to a pdf

Postby zmotiwala » Fri Apr 26, 2019 8:57 pm

I cannot upload the sample file it contains sensitive data.
Libre Office 5.2.5
Windows
zmotiwala
 
Posts: 40
Joined: Wed Dec 28, 2011 5:34 pm

Re: Disable macro execution while converting to a pdf

Postby RoryOF » Fri Apr 26, 2019 9:04 pm

Change the data so we can inspect the file.
Apache OpenOffice 4.1.6 on Xubuntu 18.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 28948
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Disable macro execution while converting to a pdf

Postby zmotiwala » Fri Apr 26, 2019 9:46 pm

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
zmotiwala
 
Posts: 40
Joined: Wed Dec 28, 2011 5:34 pm

Re: Disable macro execution while converting to a pdf

Postby Villeroy » Sat Apr 27, 2019 9:49 am

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, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26734
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Disable macro execution while converting to a pdf

Postby JeJe » Sat Apr 27, 2019 4:12 pm

You can stop an individual macro running in various ways such

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

Code: Select all   Expand viewCollapse view
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   Expand viewCollapse view
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   Expand viewCollapse view
dim something as boolean

function changeDate()
if something = true then exit function

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

end function


Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 508
Joined: Wed Mar 09, 2016 2:40 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests