Consulting

Results 1 to 7 of 7

Thread: Solved: open as read only

  1. #1
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location

    Solved: open as read only

    Hello,

    I know how to open a file as read only using the "open" dialog box i.e the arrow on the open button allows you to select to open it as read only

    Is there a way to do this from my documents. i.e. I want to open someone else's file to do some testing etc on it. I normally have the "mydocuments" window open (in real life it is the shared drive but it looks the same) and want to open it as read only from there (so I dont mess up there file). They havent set it to prompt for read only but I want to open it as read only nonetheless

    (could I have fitted the phrase read-only into this thread any more!!!)

    Cheers
    Phil

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Greetings Phil,

    Rather than using Windows Explorer or My Documents, simply open the doc, wb etc thru the application. For instance, if you open Excel first, and use File | Open, after selecting the file (workbook) in the fileopen dialog, click on the little down arrow on the <Open> button.

    Nifty, eh?

    Mark

  3. #3
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    PS - just noticed another thread by you. Lots of folks do not have 2007. So when possible, you might want to save an example wb in the .xls format, as this allows more folks to be able to view it, and hence, may get you additional help...

    Mark

  4. #4
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location
    thanks for that Mark but with all due respect I already knew about the arrow on the open button as I mentioned it in the original post

    is there anyway that anyone can think of to do the same thing through the Explorer or MyDocuments wondows

    Cheers

  5. #5
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Phil,

    Well goodness, you have my humble apologies. I just re-read your first post, and you certainly were clear in your very first sentence. Sorry about that. BTW, my 'nifty, eh' comment was not intended to be facetious at all, as I do think this is a nifty feature.

    As to opening read-only thru Windows Explorer, I learn a lot here almost daily (and maybe this will be such an occassion if a more learned member will give a better or different explanation), but in my own, albeit simple terms, I don't think this is possible.

    When opening or running a file from a window (Explorer), I believe that basically two things happen: (1) a check to see if the associated application is running. (2) [a] Create a instance of the app if an instance does not exist and [b] Open/run the file/workbook in the running or created instance of the associated application. This of course does not include the option of "Open With".

    Anyways, I don't think that Explorer checks the various applications' individual capabilities, such as Word/Excel's open read-only option.

    Again, sorry I read through your question in such a poor manner, and cheers as well,

    Mark

  6. #6
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    I know you say from explorer/my docs (i also am not sure this is possible) but can you not just use something like

    Workbooks.Open Filename:= "Blah blah blah", UpdateLinks:=3, ReadOnly:=1
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  7. #7

    CAUTION: Advanced

    Good Evening.

    Thanks to GTO for throwing another problem at me that gets my gears going. And sometimes a solution just nags at me so that I have to find a solution.

    I knew up front that Word is a very powerful application and Microsoft is very big on having their applications so that they are very versatile. At first, I thought it would just be a command line switch that is passed as an argument. I was partly correct.

    The final solution was the use of DDE or Dynamic Data Exchange.

    In Windows Vista, the File Type tab of the Folders Option is no longer available, so for those who are using Vista or XP, this method should work. Please note, this involves editing the Registry and you should always back up your registry before making changes.

    1.) Open the Registry Editor.
    a.) Start | Run | RegEdit.Exe
    2.) Open the following Keys.
    a.) Computer
    b.) HKEY_CLASSES_ROOT
    c.) Word.Document.8
    d.) Shell
    3.) Edit or Right-Click | New Key...
    Open As Read Only
    4.) Change (Default)...
    Open &As Read-Only
    5.) New Key...
    Command
    6.) Change (Default)...
    "C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE" /x /n /dde
    7.) New Multi-String Value...
    Command
    8.) Set Value Data to:
    ']gAVn-}f(ZXfeAR6.jiWORDFiles>P`os,1@SW=P7v6GPl]Xh /x /n /dde
    vUpAVX!!!!!!!!!MKKSkWORDFiles>tW{~$4Q]c@5d1`,xaTO5 /x /n /dde
    9.) From Open As Read Only Key | New Key...
    DDEExec
    10.) Change (Default)...
    [FileOpen ("""%1"""),.ReadOnly]
    11.) New Key...
    Application
    12.) Change (Default)...
    WinWord
    13.) From DDEExect | New Key...
    Topic
    14.) Change (Default)...
    System

    Close the Registry Editor and test your changes.


    For simplicity sake, I've attached an Export of the changes to the Registry. Open the Zip File and open the file titled 'OpenAsReadOnly.reg'. Your Zip Program may tell you it is dangerous to open this type of file. It will tell you that the Key and values contained were added. Test the solution.


    References:
    Microsoft Developer's Network: Knowledge Base Q210565

    Good Luck!
    Scott
    You don't understand anything until you learn it more than one way. ~Marvin Minsky

    I never teach my pupils; I only attempt to provide the conditions in which they can learn. - Albert Einstein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •