PDA

View Full Version : VBA to stop showing EXCEL icon on the Windows Task Bar -Access Opening/Closing Excel



maxis
11-10-2017, 10:12 AM
Our Access Database (2003 format) opens and closes an Excel spreadsheet (.xlsm) up to 100 times to do inter-related calculations. Designed many years ago, Access opens the spreadsheet, the spreadsheet does the calculation, then Access closes the spreadsheet and keeps the results. It does it over and over again until the amounts come within a certain threshold. That's the nature of the inter-related calculations (over my head).

For our users running Office 2010 it works just fine. But we recently started upgrading to Office 365 (2016) and this same process causes the screen to flash because you can actually see the spreadsheet opening and closing, as well as Windows displaying the EXCEL icon on the Windows Task Bar. The calculations all work, but with Office 365 all these behind the scene opening and closing of the spreadsheets that went unnoticed in Office 2010 make the screen "flash" because it appears that it simply doesn't run as well in Office 2016 with regards to doing all these behind the scenes opens/closes.

Our question is whether or not there is something in Access vba that could turn off the "showing Excel icon on the task bar" and/or "the opening and closing of the spreadsheet". The only analogy is like the ECHO OFF in DOS. Commands are being executed BUT NOT DISPLAYED to the user. Is there something similar in ACCESS vba that would "not display" or "turn off" these extra steps that Access/Excel are doing assuming the spreadsheet is being open for User input instead of behind the scene calculations? Kind of like "working in invisible mode" while you're doing all those behind the scene opens/closes - we never really have to see the spreadsheet that's being opened/closed.

Thank you.

OBP
11-10-2017, 10:43 AM
Can you show the code that opens the Excel sheet?
You could try turning off System Warnings and Messages before the Excel manipulations with

DoCmd.SetWarnings False

and turn them back on again afterwards with

DoCmd.SetWarnings True

Access does have the same Echo Off as DOS which prevents the screen repainting

Application.Echo False

and turn it back on with

Application.Echo True

maxis
11-10-2017, 11:49 AM
I actually found the code and it's already set to FALSE. In Office 2010 it works, In Office 2016 (365) it shows Excel opening/closing the spreadsheet. The "flash" or "blink" is the open/close of the spreadsheet in Office 2016. It only takes a 1/2 second, but it does it in Office 2016 and NOT Office 2010.

Do you think this is a know ISSUE with Office 2016? That's crazy! I didn't realize there was a .visible for the application you're calling FROM ACCESS with vba, but I think it's THERE, it's just NOT working.

Looking for additional clues/hints. blnVisible = FALSE


pobjBook.Windows(1).Visible = blnVisible
pobjExcel.Visible = blnVisible

OBP
11-10-2017, 12:05 PM
Yes but the code that I provided is working on the Access Window, not the Excel one, so it should be worth a try at least.

maxis
11-10-2017, 12:15 PM
Because the spreadsheet is mainly used "behind the scenes" the workbook_open event has a single line of code to default to the "menu" tab.


Sheets("Menu").Select

maxis
11-10-2017, 12:27 PM
I added the third line and now the "spreadsheet" doesn't display (THIS IS GOING IN THE RIGHT DIRECTION), but the EXCEL icon turns off/on at the bottom of the screen in the Windows Task Bar. Which .visible property would that be?




pobjBook.Windows(1).Visible = blnVisible
pobjExcel.Visible = blnVisible
pobjSheet.Visible = blnVisible

OBP
11-10-2017, 12:36 PM
Did you try the Set Warnings as well?
Is it the Windows Task Bar or the Access Bottom Bar?

OBP
11-10-2017, 12:42 PM
Have tried the more normal Visible VBA code ie
AppExcel.Visible = True or AppExcel.Visible = False

maxis
11-10-2017, 01:07 PM
Definitely Windows Task Bar.

maxis
11-10-2017, 01:25 PM
By accident I commented out all three lines of code and now in Office 365 (2016) it doesn't display the spreadsheet or the Excel icon on the Windows Task Bar. It works with the 3 lines of code commented out. What the heck; now I'm just confused.

OBP
11-11-2017, 02:04 AM
Well, it looks as if those lines are actually redundant, as it works OK You could probably delete them.
At least you have fixed it.
VBA can be like that sometimes.

PhilS
11-11-2017, 11:52 PM
It works with the 3 lines of code commented out. What the heck; now I'm just confused.

What as the value of blnVisible in your code? If it was true you were explicitly displaying the Excel windows and the observed behavior was perfectly logical.