Results 1 to 7 of 7

Thread: [RESOLVED] Open excel file in read only mode

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Location
    India
    Posts
    23

    Resolved [RESOLVED] Open excel file in read only mode

    I want to open office files say...excel in read only mode thru my vba.can anyone plz help me out.i can open them but cant specify the access modes.
    can anybody please help me out......

  2. #2
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: Open excel file in read only mode

    Why don't you change the file attributes to Read Only before you open it? Or can't you change file attributes in VBA?
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  3. #3
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Open excel file in read only mode

    The best way would be to use Command Line switches. To open a file as Readonly you can use
    Code:
    Excel.EXE /r myFile.xls
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Open excel file in read only mode

    VB Code:
    1. Dim oApp As Excel.Application
    2. Set oApp = New Excel.Application
    3. oApp.Workbooks.Open Filename:="C:\MyFile.xls", ReadOny:=True


    Ps, Congrats Shuja Ali on your 700 posts!
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Open excel file in read only mode

    Quote Originally Posted by RobDog888
    Ps, Congrats Shuja Ali on your 700 posts!
    Thanks
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Location
    India
    Posts
    23

    Resolved Re: Open excel file in read only mode

    Thanks a lot.....
    This helped me again..

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Open excel file in read only mode

    Quote Originally Posted by cswaroopsaha
    Thanks a lot.....
    This helped me again..
    If this is resolved, please pull down the Thread Tools menu and click the Mark Thread Resolved button. That will let everyone know that you have your answer.

    Thank you.

Posting Permissions

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



Click Here to Expand Forum to Full Width