Extracting file in read only mode

Posted on 2006-04-17
Last Modified: 2013-12-18
I have a PowerBuilder app that uses OLE to ExtractFile which is stored in Lotus Notes.  We would like to put some security on our documents so only the original owner of the document can modify the document and all other users can only open the document in read only mode.  

The code currently looks something like this:
ole_NotesDatabase = ole_NotesSession.GetDatabase ( is_notes_svr, is_notes_filepath)
IF ole_NotesDatabase.IsOpen = True Then
    ole_embeddedobject.ExtractFile ( is_new_file_path  )
end if

Is there a way to open the doc in ready mode only?
Question by:slim7
    LVL 63

    Expert Comment

    The read mode will not prohibit OLE attachment file extract. It is a document read operation.


    Author Comment

    So do I need to put in logic that if it is the original owner then extractfile, else  openfile in read mode?  If so, how do I open it in read mode?
    LVL 18

    Expert Comment

    Are you askig about the attached file or the Notes Document?  Your posted code is missing a few steps since it doesn't identify the document where the file is attached.

    The attached file has the properties the OLE object sets.  Therefore if the attached/detached file had the attributes:  ReadOnly, then it would only be opened in READ mode .. however, file attributes would not deter someone from changing the file attributes.

    The answer to your question is that the attached file needs to have security, password, etc., saved with it before you attach it.  Or, you need to use the file available activeX commands to password protect it if the owner isn't the reader after you detach it.   Even if I wanted to do this in Notes, I would first have to detach the file,  set a password using the original program commands, and then reattach it.

    Does this help?

    Author Comment

    Well, yes and no...we are trying to avoid passwords to protect the attached file because people forget it and those kind of problems.  So ideally I'd like to check if the user is the original owner and then decide whether to detach the file (so they can edit it) or to open it up so they can only read the file.
    LVL 18

    Expert Comment

    Unfortunately, that can only be done by the program that created the file, and not in Notes.   For instance, I can attach an Excel file, as long as I have read access to the document in Notes, the attachment will show up, and I can detach it, or open it.

    In Notes, you can decide if you want to VIEW a file, and so Notes uses the program's file viewer.. i.e. excel viewer, word viewer, to open and VIEW the file in Notes.  If the appropriate exe viewers are available, then you can decide if you're going to shell to the original program or to the viewer program.  

    But this won't disable the ability to edit the file.

    Now, in Notes, if you detach the file, the original still sits in the Notes Document, same as for Word or Excel, and opening them you usually open temp file, and not the original.   This file they can edit all they like, since the original sits in the Notes Document.

    I handle this type of even in PDF files, because that assumes the owner has the original, and if changes need to be made, you just roll up another PDF.  This way I can password protect the PDF, and I don't care if anyone loses the password, because the original is sitting somewhere else.

    In fact, I make a point of never remembering the password on the PDF files. :)


    Author Comment

    I haven't looked but command would launch a viewer?  Most of our docs are word, excel or pdf.  Thanks for giving me some direction on how to handle.
    LVL 18

    Accepted Solution

    Excel and Word viewers are available at

    Now, @urlOpen will open the excel, word or pdf file, but the excel and word files will be editable.  So you can use that to open the pdf file.

    Something like this will open an excel file in READ mode only:

    Sub Click(Source As Button)
          Dim ws As New NotesUIWorkspace
          Dim uidoc As NotesUIDocument
          Set uidoc=ws.currentdocument      
          Dim xlFilename As String
          xlFilename= uidoc.FieldGetText("xlFile")
          If Len(xlFilename)<1 Then
                Msgbox "Please enter the filename in the field: xlfile",,"No Filename Specified"
                Exit Sub
          End If
          On Error Goto Handle_Error
         'First Connect to Excel and see if there are any records to import......................
          Dim Excel As Variant
          Dim xlWorkbook As Variant
          Dim xlSheet As Variant
          Const xlupdateLinks=2
          Dim xlReadOnly As Variant
          xlReadOnly = True
          Print "Connecting to Excel..."
          Set Excel = CreateObject( "Excel.Application" )
          If Excel Is Nothing Then
                Print "Unable to open the excel object..."
                Exit Sub
          End If
          Excel.Visible = True
          Excel.Workbooks.Open xlFilename,xlUpdateLinks,xlReadOnly
          Print "Opening " & xlFilename & "..."
          Set Excel = Nothing '// Free the memory that we'd used
          Exit Sub
          If Err = 213 Then
                Msgbox  "Sorry, Excel file: " + xlfilename + " could not be found",,"Unable to Continue"
                Err = 0
                Exit Sub
          End If
          On Error Goto 0
          If Not xlworkbook Is Nothing Then
                Excel.activeworkbook.close         '// Close the Excel file without saving (we made no changes)
                Excel.Quit '// Close Excel
                Set Excel = Nothing '// Free the memory that we'd used
          End If
          Exit Sub
    End Sub

    See here for the excel open method:

    See here for WORD open methods:

    Author Comment

    Great, thank you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
    For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now