Trying to open the workbook in separate instance

后端 未结 2 1606
后悔当初
后悔当初 2020-12-02 02:28

Not sure whether I am doing it right. Please advise me.

I am trying to open one workbook in new instance. But some where it is not working fine. Below is the code fo

2条回答
  •  萌比男神i
    2020-12-02 03:00

    I'm just a newbie, but this worked for me. This code appears to open your file in a new instance of Excel. Copy and paste this vba code into the ThisWorkBook object:

    Option Explicit
    
    Dim objExcel As Excel.Application
    
    Dim FileName As String
    
    Public Sub workbook_open()
        FileName = ThisWorkbook.FullName
        If vbReadOnly <> 0 Then
            Exit Sub
        Else
            objExcel.Workbooks.Open FileName:=FileName
            ThisWorkbook.Saved = True
            ThisWorkbook.Close
            objExcel.Quit
        End If
    End Sub
    

提交回复
热议问题