My recent upgrade to Office 365 / Excel 2016 caused some unwanted behavioral changes. Workbook ("Portfolio Evaluation") contains the Workbook_open procedure, which checks if the Workbook ("Index Returns") is open; if it is not, he will open this book.
In Excel 2007, Index Returns will open in the background and stay there, which is the desired behavior. It will be βin the windowβ and can be viewed in the same Excel window using the Arrange All option on the Window tab of the View ribbon.
In Excel 2016, if it opens with the Workbook_Open procedure, Index Returns opens in its Excel window and ends in front. (It can no longer be viewed in the same Excel window as Portfolio Appreciation ).
The fact that Index Returns is ahead is a problem.
I tried selecting and deselecting to ignore other applications using DDE; I tried the AppActivate method (shown in the code below) and confirmed with MsgBox that the argument matches the corresponding header line.
Not sure where to go next. Suggestions appreciated.
Also: Index Returns does not contain macros or joins. Portfolio Appreciation does not contain macros other than Workbook_Open , and it has a web request that is updated when it is opened (the request downloads some stock index data).
Option Explicit Private Sub Workbook_Open() Dim wbs As Workbooks, wb As Workbook Dim IndexReturns As String Dim re As RegExp Const sPat As String = "(^.*\\DATA\\).*" Const sRepl As String = "$1EHC\Investment Committee\indexreturns.xlsb" Dim sTitle As String sTitle = Application.Caption Set wbs = Application.Workbooks Set re = New RegExp With re .Pattern = sPat .Global = True .IgnoreCase = True End With IndexReturns = re.Replace(ThisWorkbook.FullName, sRepl) For Each wb In wbs If wb.FullName = IndexReturns Then Exit Sub Next wb Application.ScreenUpdating = False wbs.Open (IndexReturns) Set re = Nothing AppActivate sTitle 'sTitle contains title of thisworkbook 'The below doesn't work either 'AppActivate ThisWorkbook.Application.Caption Application.ScreenUpdating = True End Sub
source share