Open as read only from same folder - on any PC

  • Hello Wizards,


    Code below works on my PC – it opens file ABCD.xlsm as read only from the same folder where I have the file with this code in it, then closes this workbook.
    Problem is that when I open this workbook on another person’s PC, gives error – can’t find .\ABCD.xlsm
    When I got rid of that dot before the backslash I got same error even on my PC…

    Code
    1. [I]Private Sub Workbook_Open()[/I]
    2. [I]Workbooks.Open Filename:=".\ABCD.xlsm", ReadOnly:=True[/I]
    3. [I]ThisWorkbook.Close[/I]
    4. [I]End Sub[/I]
  • Try this, the workbook ABCD must be in the same folder as the one with the code


    Code
    1. Option Explicit
    2. Private Sub Workbook_Open()
    3. Workbooks.Open Filename:=ThisWorkbook.Path & Application.PathSeparator & "ABCD.xlsm", ReadOnly:=True
    4. ThisWorkbook.Close
    5. End Sub