Problems suppressing the "Update Links?" dialog

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
pstraton
Posts: 1
Joined: Tue Feb 11, 2014 11:24 pm

Problems suppressing the "Update Links?" dialog

Post by pstraton »

I'm brand-new to OpenOffice, StarBasic, and the OpenOffice object model. Lots of experience with MS/VBA, and my task at hand is to port a small amount of moderately sophisticated VBA functionality to OpenOffice Calc in StarBasic. That functionality includes the need to open multiple files in a particular state/mode, and I've found enough information about com.sun.star.beans.PropertyValue to be dangerous.

In particular, the files I'm opening are Excel ".xlsm" workbooks that sometimes result in the "This file contains links to other files. Should they be updated? [Yes] [No]" dialog being displayed. I don't need any links to be updated for my purposes and don't want the user to have to get involved, so I set "UpdateDocMode" property to "NO_UPDATE" in the file-open operation as follows:

Code: Select all

Dim SaveProperties(1) As New com.sun.star.beans.PropertyValue
FileProperties(0).Name = "MacroExecutionMode"
FileProperties(0).Value ="NEVER_EXECUTE"
FileProperties(1).Name = "UpdateDocMode"
FileProperties(1).Value = "NO_UPDATE"
SrcFile = StarDesktop.loadComponentFromURL(FilePath, "_blank",0 ,FileProperties())
Yesterday, I was unable to get this to work as expected, with it continuing to pop the dialog inquiry. Today, I began experimenting to identify other variables that might be involved, such as setting Tools=>Options=>OpenOffice Calc=>General=>Updating to "Never" (or back to "On Request"), and setting ThisComponent.IsExecuteLinkEnabled to False (or back to True), to see if/how they affected the behavior of my file-open code, above. At some point today my code started working correctly and, unfortunately, I didn't do a controlled enough experiment to understand what I did to get it working--too many variables at play. Further, I can now set Tools=>Options=>OpenOffice Calc=>General=>Updating to "On Request" and ThisComponent.IsExecuteLinkEnabled to True (presumably the state they were in yesterday before I started messing with them, when my code didn't work) and now it works even with these settings.

I also did some additional investigation and discovered the "LinkUpdateMode" property, but none of the documentation I can find clearly describes its functionality, especially with regard to how it is different from "UpdateDocMode". (Actually, the documentation for "UpdateDocMode" is pretty vague too.)

So I have four basic questions:

1. What is the difference between the "UpdateDocMode" and "LinkUpdateMode" properties?
2. How do properties like "UpdateDocMode" and/or "LinkUpdateMode" interact with the Tools=>Options=>OpenOffice Calc=>General=>Updating setting?
3. How do properties like "UpdateDocMode" and/or "LinkUpdateMode" interact with the current state of the ThisComponent.IsExecuteLinkEnabled property?
4. Is there something more subtle or obscure going on (such as exiting OpenOffice and restarting it, or some such) that would explain why code that didn't work yesterday now works, under apparently the same conditions?

Thanks in advance for any help.
OpenOffice 4.0.1, installed on Windows XP
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Problems suppressing the "Update Links?" dialog

Post by Villeroy »

The property values are UNO constants. You specified strings.
http://www.openoffice.org/api/docs/comm ... iptor.html
http://www.openoffice.org/api/docs/comm ... cMode.html
http://www.openoffice.org/api/docs/comm ... cMode.html

Code: Select all

FileProperties(0).Value =com.sun.star.document.UpdateDocMode.NEVER_EXECUTE
FileProperties(1).Value = com.sun.star.document.MacroExecMode.NO_UPDATE
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
NicolasLD
Posts: 1
Joined: Wed Jul 12, 2017 12:34 pm

Re: Problems suppressing the "Update Links?" dialog

Post by NicolasLD »

I got the same problem, I can't cancel the dialog box after loading component.

Code: Select all

var openProps = new PropertyValue[4];
openProps[0] = new PropertyValue { Name = "UpdateDocMode", Value = new uno.Any(typeof(int), 0) };
openProps[1] = new PropertyValue { Name = "MacroExecutionMode", Value = new uno.Any(typeof(int), 0) };
openProps[2] = new PropertyValue { Name = "ReadOnly", Value = new uno.Any(typeof(bool), true) };
openProps[3] = new PropertyValue { Name = "Hidden", Value = new uno.Any(true) };
var xComponent = Loader.loadComponentFromURL(filePath, "_blank", 0, openProps);
Did you solve your problem ?
OpenOffice version : 5.2.7.2
Post Reply