Date: 18/09/2016 21:42:15
From: KJW
ID: 957165
Subject: Excel 2016

I have a workbook that opens another workbook and prints data from the second workbook. The following is from the section of code from the first workbook that opens the second workbook (code that is irrelevant to the question has been modified or removed):

Application.ScreenUpdating = False Application.DisplayAlerts = False Dim wb_original As Workbook Dim ws_original As Worksheet Set wb_original = Application.ActiveWorkbook Set ws_original = Application.ActiveSheet Set opened_workbook = Workbooks.Open(filename) wb_original.Activate ws_original.Activate Application.DisplayAlerts = True Application.ScreenUpdating = True

This code was written for Excel 2010 and works as intended in that version of Excel. In Excel 2016, it does not work as intended.

In Excel 2010, after the code has completed, the worksheet in the first workbook from which the opening of the second workbook is triggered is displayed. By contrast, in Excel 2016, it is the opened workbook that is displayed after the code has completed.

Looking through Excel 2016 Help (!!!), I see mention of a difference between Excel 2016 and Excel 2010 regarding Single Document Interface and Multiple Document Interface that may be relevant, although I have not grasped the precise details.

I’m looking for advice from those familiar with Excel 2016.

Reply Quote

Date: 18/09/2016 21:46:54
From: KJW
ID: 957166
Subject: re: Excel 2016

I’ll repost the code:

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim wb_original As Workbook
Dim ws_original As Worksheet
Set wb_original = Application.ActiveWorkbook
Set ws_original = Application.ActiveSheet
Set opened_workbook = Workbooks.Open(filename)
wb_original.Activate
ws_original.Activate
Application.DisplayAlerts = True
Application.ScreenUpdating = True

Reply Quote

Date: 19/09/2016 11:33:28
From: furious
ID: 957258
Subject: re: Excel 2016

I am unable to test in Excel 2016 and I don’t have a requirement to do exactly what you need but I have a memory of doing similar type of things. In one example I could find, I create a new workbook from a sheet in the current one and then return to the current one when it is done. Cutting out all the other data, I have:

thisBook = ActiveWorkbook.Name
‘…Other stuff…
Windows(thisBook).Activate

I don’t return to the original sheet as it has been moved to a new workbook but that can be achieved, similarly e.g.

thisBook = ActiveWorkbook.Name
thisSheet = ActiveSheet.Name
‘…etc…
Windows(thisBook).Activate
Sheets(thisSheet).Activate

Reply Quote

Date: 19/09/2016 23:05:09
From: KJW
ID: 957484
Subject: re: Excel 2016

furious said:


I am unable to test in Excel 2016

At home I use Excel 2016 under Windows 7, whereas at work I have been recently upgraded to Excel 2016 under Windows 10.

furious said:


Windows(thisBook).Activate

I have always avoided using the Windows object. My investigation seems to indicate that this would be affected by the upgrade to Excel 2016.

Reply Quote

Date: 20/09/2016 00:43:40
From: KJW
ID: 957495
Subject: re: Excel 2016

KJW said:


At home I use Excel 2016 under Windows 7

Correction:

At home I use Excel 2010 under Windows 7

Reply Quote

Date: 20/09/2016 10:25:02
From: furious
ID: 957649
Subject: re: Excel 2016

Why is that? I probably do a lot of things that should be avoided, mostly becuase I don’t know that they should be avoided…

I still can’t replicate in Excel 2016 because I have W7 and Excel 2010 at work but I can split the difference as I also have access to a W10/Excel 2013 combination.

I created your code in 2010 and it worked as intended. I did the same with mine and it also worked the same way.

Opening the same Excel file with the two codes on the W10/2013 system and yours didn’t work in the same manner as you describing it not working above. I ran mine and it worked as intended.

However, for brevity, in mine I did not include:

Application.ScreenUpdating = False/True
Application.DisplayAlerts = False/True

So I removed them from yours and then it worked as intended…

Reply Quote

Date: 20/09/2016 10:58:01
From: The Rev Dodgson
ID: 957674
Subject: re: Excel 2016

No time right now, but I’ll try and have a look with Excel 2016/Windows 10 later today.

Reply Quote

Date: 20/09/2016 16:27:21
From: stan101
ID: 957832
Subject: re: Excel 2016

KJW, what happens if you call the sheet directly at the end of the code? Example:

Workbooks(“your_original_workbook.xlsx”).Activate

Sheets(“your_original_worksheet”).Select

Or even make the above two lines a sub and call that sub at the end of the code?

There are quite a few little variances between 2007 office and te newer versions, but I wasn’t aware of too many changes in 2016.

Reply Quote

Date: 20/09/2016 19:42:45
From: KJW
ID: 957961
Subject: re: Excel 2016

furious said:


I also have access to a W10/Excel 2013 combination.

I have access to Excel 2013 under Windows 10 at work, but not on my workstation. I don’t know how Excel 2013 behaves running my code, though it is not clear if there is any benefit to finding out (apart from knowledge for its own sake).

Reply Quote

Date: 20/09/2016 19:45:18
From: furious
ID: 957962
Subject: re: Excel 2016

Okay, sorry I bothered…

Reply Quote

Date: 20/09/2016 19:47:31
From: furious
ID: 957963
Subject: re: Excel 2016

For what its worth this:

appears to have happened when they went to 2013 and it is probably the cause of your issue…

Reply Quote

Date: 20/09/2016 19:52:24
From: Witty Rejoinder
ID: 957965
Subject: re: Excel 2016

furious said:

Okay, sorry I bothered…

You’ll go far on this forum. Godspeed!

Reply Quote

Date: 20/09/2016 20:01:20
From: KJW
ID: 957975
Subject: re: Excel 2016

furious said:

  • I don’t know how Excel 2013 behaves running my code, though it is not clear if there is any benefit to finding out (apart from knowledge for its own sake).

Okay, sorry I bothered…

What I meant was that because my code needs to run on Excel 2016 and not on Excel 2013, how it runs on Excel 2013 is immaterial to my needs.

Reply Quote

Date: 20/09/2016 20:05:11
From: KJW
ID: 957981
Subject: re: Excel 2016

KJW said:


furious said:
  • I don’t know how Excel 2013 behaves running my code, though it is not clear if there is any benefit to finding out (apart from knowledge for its own sake).

Okay, sorry I bothered…

What I meant was that because my code needs to run on Excel 2016 and not on Excel 2013, how it runs on Excel 2013 is immaterial to my needs.

… and testing the code in an Excel 2013 machine at work is probably more effort than it’s worth.

Reply Quote

Date: 20/09/2016 20:06:20
From: furious
ID: 957983
Subject: re: Excel 2016

That’s how I feel…

Reply Quote

Date: 20/09/2016 22:17:14
From: The Rev Dodgson
ID: 958027
Subject: re: Excel 2016

furious said:


However, for brevity, in mine I did not include:

Application.ScreenUpdating = False/True
Application.DisplayAlerts = False/True

So I removed them from yours and then it worked as intended…

I just tried this in 2016 and it works also, i.e.

with:
Application.ScreenUpdating = False/True
Application.DisplayAlerts = False/True

it doesn’t return to the first file.

with:
Application.ScreenUpdating = False and Application.DisplayAlerts = False commented out

It does return to the first file.

I tried with the =False statements reactivated, and the =True statements moved to before the wb_original.Activate, ws_original.Activate, but that didn’t work.

Reply Quote

Date: 23/09/2016 18:50:49
From: KJW
ID: 959317
Subject: re: Excel 2016

The Rev Dodgson said:


furious said:

However, for brevity, in mine I did not include:

Application.ScreenUpdating = False/True
Application.DisplayAlerts = False/True

So I removed them from yours and then it worked as intended…

I just tried this in 2016 and it works also, i.e.

with:
Application.ScreenUpdating = False/True
Application.DisplayAlerts = False/True

it doesn’t return to the first file.

with:
Application.ScreenUpdating = False and Application.DisplayAlerts = False commented out

It does return to the first file.

I tried with the =False statements reactivated, and the =True statements moved to before the wb_original.Activate, ws_original.Activate, but that didn’t work.

Unfortunately, I didn’t get the opportunity at work since you wrote this to try this… maybe next week.

Reply Quote

Date: 23/09/2016 18:51:58
From: furious
ID: 959320
Subject: re: Excel 2016

Have you been at work since I suggested the exact same thing earlier?

Reply Quote

Date: 23/09/2016 18:58:04
From: KJW
ID: 959330
Subject: re: Excel 2016

furious said:

  • Unfortunately, I didn’t get the opportunity at work since you wrote this to try this… maybe next week.

Have you been at work since I suggested the exact same thing earlier?

That was the same day… so no.

Reply Quote

Date: 23/09/2016 19:08:11
From: KJW
ID: 959346
Subject: re: Excel 2016
Application.ScreenUpdating

It will be an angry moment if I’m forced to see, even briefly, the workbook that is opened. That is, I don’t consider removing Application.ScreenUpdating from my code to be an acceptable solution.

Reply Quote

Date: 23/09/2016 19:32:34
From: KJW
ID: 959368
Subject: re: Excel 2016

On a side note, while on the topic of Excel 2016, one other thing that has made me feel dismay is the absence of offline Help. For Excel 2010, even with the choice between online and offline Help , I chose the offline Help because I felt it was much better.

Apparently, the link to online Help for Excel 2010 is currently broken.

Reply Quote

Date: 23/09/2016 20:17:52
From: The Rev Dodgson
ID: 959382
Subject: re: Excel 2016

KJW said:


On a side note, while on the topic of Excel 2016, one other thing that has made me feel dismay is the absence of offline Help. For Excel 2010, even with the choice between online and offline Help , I chose the offline Help because I felt it was much better.

Apparently, the link to online Help for Excel 2010 is currently broken.

I totally agree. Not only is the on-line help much slower to open, it has been completely re-written and is now much worse than it was.

On the other hand your objection to the second worksheet flashing briefly on the screen seems just a little bit picky :)

Reply Quote

Date: 23/09/2016 21:16:22
From: KJW
ID: 959454
Subject: re: Excel 2016

The Rev Dodgson said:


On the other hand your objection to the second worksheet flashing briefly on the screen seems just a little bit picky :)

In itself, the brief flashing on the screen is not much of a problem. But considering that I may have to replace code that is both logically correct and works in Excel 2010 with code that is both logically flawed and doesn’t quite work in Excel 2016, I feel justified in being peeved. Why are we even buying Excel 2016? Is it that we are just being bullied by M$? They tell us that they are improving our experience with their product, but I’m not seeing the improvement. :-(

Reply Quote

Date: 18/10/2016 19:29:20
From: KJW
ID: 969791
Subject: re: Excel 2016

KJW said:


In itself, the brief flashing on the screen is not much of a problem.

I eventually got the opportunity at work to try commenting out the Application.ScreenUpdating lines in the actual real-world code. To my surprise, the result wasn’t as bad as I had expected. The opened workbook wasn’t seen but instead was the brief flashing of a blank window. I’ve noticed that Excel 2016 displays such a blank window while the VBA code is busy running.

Reply Quote

Date: 18/11/2016 22:27:01
From: KJW
ID: 983252
Subject: re: Excel 2016

KJW said:


In itself, the brief flashing on the screen is not much of a problem.

I eventually got the opportunity at work to try commenting out the Application.ScreenUpdating lines in the actual real-world code. To my surprise, the result wasn’t as bad as I had expected. The opened workbook wasn’t seen but instead was the brief flashing of a blank window. I’ve noticed that Excel 2016 displays such a blank window while the VBA code is busy running.

Reply Quote