I am trying to open one "Excel Macro-Enabled Workbook (.xlsm) file from another "Excel Macro-Enabled Workbook (.xlsm). I am using the following code to perform the task.
Private Sub Workbook_Open()
If Not isBookOpen("REFERENCE_FILE.xlsm") Then
tplateWorkBook = ActiveWorkbook.Name
windowIndex = Application.ActiveWindow.Index
refFile = ActiveWorkbook.Path & "\REFERENCE_FILE.XLSM"
If Not Dir(refFile, vbDirectory) = vbNullString Then
Workbooks.Open refFile
Application.ActiveWindow.Visible = False
Application.Workbooks(tplateWorkBook).Activate
Application.Windows(windowIndex).Visible = True
Else
MsgBox "Reference file is missing, LOV will not work." & Chr(13) & "Place a copy of updated Reference File on the same folder as your templates." & Chr(13), vbCritical + vbOKOnly, "Reference File Missing"
End If
End If
End Sub
Function isBookOpen(wbName As String) As Boolean
Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks(wbName)
isBookOpen = Not (Err.Number > 0)
Exit Function
End Function
This code is work fine for windows 10 Pro, version 21H2 and OS build 19044.1526. However above this OS build (like 19044.2604) this does not work.