Page 1 of 1

Disable macro execution while converting to a pdf

PostPosted: Thu Apr 25, 2019 3:33 am
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.

Re: Disable macro execution while converting to a pdf

PostPosted: Thu Apr 25, 2019 6:18 am
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)

Re: Disable macro execution while converting to a pdf

PostPosted: Thu Apr 25, 2019 12:02 pm
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.

Re: Disable macro execution while converting to a pdf

PostPosted: Fri Apr 26, 2019 8:57 pm
by zmotiwala
I cannot upload the sample file it contains sensitive data.

Re: Disable macro execution while converting to a pdf

PostPosted: Fri Apr 26, 2019 9:04 pm
by RoryOF
Change the data so we can inspect the file.

Re: Disable macro execution while converting to a pdf

PostPosted: Fri Apr 26, 2019 9:46 pm
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?

Re: Disable macro execution while converting to a pdf

PostPosted: Sat Apr 27, 2019 9:49 am
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

Re: Disable macro execution while converting to a pdf

PostPosted: Sat Apr 27, 2019 4:12 pm
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   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