vba Open excel when File is used by another user

后端 未结 3 690
我在风中等你
我在风中等你 2021-01-26 06:16

This is my current code

Public Sub OpenFiles()
    \'Set LiveDealSheet file path
    \'Check if LiveDealSheet is already open
    LDSP = \"C:\\Users\\DCHEUNG\\De         


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-26 07:01

    I would replace all the scripted above with this:

    Public Sub OpenFiles()
            On Error GoTo not_open
            Workbooks("C:\Users\DCHEUNG\Desktop\Programing\LiveDealSheet.xlsm").Activate
            Exit Sub
            not_open:
            Workbooks.Open FileName:="C:\Users\DCHEUNG\Desktop\Programing\LiveDealSheet.xlsm", ReadOnly:=True
            Err.Clear
            Resume Next
    End Sub
    

提交回复
热议问题