Page 1 of 1

[Solved] Disable read-only warning

Posted: Thu Jan 18, 2024 3:46 am
by wanglong
When I switch to read-only mode,I will get a warning prompt 'The document opens in read-only mode'.How to disable this feature?

Re: How to disable message prompt in read-only mode

Posted: Thu Jan 18, 2024 5:42 am
by FJCC
What exactly are you doing? Are you changing the read-only status with a macro? If so, please show your code.

Re: How to disable message prompt in read-only mode

Posted: Thu Jan 18, 2024 5:46 am
by wanglong
No,I want to load Doc in read-only mode.

Code: Select all

            java.io.File sourceFile = new java.io.File(filePath);
            StringBuffer sTemplateFileUrl = new StringBuffer("file:///");
            sTemplateFileUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
            String loadUrl = sTemplateFileUrl.toString();

            PropertyValue[] loadProps = new PropertyValue[3];
            loadProps[0] = new PropertyValue();
            loadProps[0].Name = "AsTemplate";
            loadProps[0].Value = false;

            loadProps[1] = new PropertyValue();
            loadProps[1].Name = "Hidden";
            loadProps[1].Value = false;

            loadProps[2] = new PropertyValue();
            loadProps[2].Name = "ReadOnly";
            loadProps[2].Value = true;

            //Get the office process to load the URL
            aBean.loadFromURL( loadUrl, loadProps );

Re: How to disable message prompt in read-only mode

Posted: Thu Jan 18, 2024 5:50 am
by wanglong
I don't want documents that I opened in read-only mode in this OPEN to go back to editable mode

Re: How to disable message prompt in read-only mode

Posted: Thu Jan 18, 2024 7:12 am
by FJCC
This BASIC macro does not produce a warning when opening the document. I don't know what about your macro causes different behavior.

Code: Select all

DIM props(0) as NEW com.sun.star.beans.PropertyValue
props(0).Name = "ReadOnly"
props(0).Value = TRUE

oDoc = StarDesktop.loadComponentFromURL(convertToURL("C:\Users\fjcc\Desktop\forumAnswer.odt"),  0, "_blank", props())

Re: How to disable message prompt in read-only mode

Posted: Thu Jan 18, 2024 9:04 am
by wanglong
I forgot to mention that I used Libre Office, not Open Office. :crazy: