私がそれを正しく行っているかどうかはわかりません。教えてください。
新しいインスタンスで 1 つのワークブックを開こうとしています。しかし、それがうまく機能していない場所もあります。以下、参考までにコードです。新しいインスタンスで「Loginfrm」という名前のフォームを開こうとしています。
別のワークブックが既に開いている場合、現在のコードがそのワークブックもフリーズするとします。理想的には、これは起こらないはずです。
Private Sub Workbook_Open()
Call New_Excel
Dim xlWrkBk As Excel.Workbook
Dim xlApp As New Excel.Application
Set xlWrkBk = xlApp.ActiveWorkbook
xlApp.Visible = True
'ThisWorkbook.Windows(1).Visible = False
LoginFrm.Show
End Sub
Sub New_Excel()
'Create a Microsoft Excel instance via code
'using late binding. (No references required)
Dim xlApp As Object
Dim wbExcel As Object
'Create a new instance of Excel
Set xlApp = CreateObject("Excel.Application")
'Open workbook, or you may place here the
'complete name and path of the file you want
'to open upon the creation of the new instance
Set wbExcel = xlApp.Workbooks.Add
'Set the instance of Excel visible. (It's been hiding until now)
xlApp.Visible = True
'Release the workbook and application objects to free up memory
Set wbExcel = Nothing
Set xlApp = Nothing
End Sub