[Solved] Disable read-only warning

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
wanglong
Posts: 51
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

[Solved] Disable read-only warning

Post 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?
Last edited by MrProgrammer on Wed Feb 28, 2024 6:38 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
Libre Office 7.6 on Windows 11.
FJCC
Moderator
Posts: 9283
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

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

Post by FJCC »

What exactly are you doing? Are you changing the read-only status with a macro? If so, please show your code.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
wanglong
Posts: 51
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

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

Post 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 );
Libre Office 7.6 on Windows 11.
wanglong
Posts: 51
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

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

Post by wanglong »

I don't want documents that I opened in read-only mode in this OPEN to go back to editable mode
Libre Office 7.6 on Windows 11.
FJCC
Moderator
Posts: 9283
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

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

Post 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())
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
wanglong
Posts: 51
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

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

Post by wanglong »

I forgot to mention that I used Libre Office, not Open Office. :crazy:
Libre Office 7.6 on Windows 11.
Post Reply