Albert Siagian
Guest
|
Hello,
I have code as follows (Add-in Express 8.01)
Dim ci = AddinModule.CurrentInstance
Dim ExcelApp = ci.ExcelApp
ExcelApp.ScreenUpdating = False
Dim wb As Excel.Workbook = ExcelApp.ActiveWorkbook
ExcelApp.Workbooks.Add()
wb.Activate()
ExcelApp.ScreenUpdating = True
In XL 2010 32-bit, it works fine, that it activates original Workbook (i.e. Book1). However, in XL 2016 32-bit, it stays in the new Workbook (i.e. Book2). The only way to return to Book1, is not to use ScreenUpdating = False.
Any idea to solve this issue, as I need ScreenUpdating = False ?
Thanks
Albert |
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
Hello Albert,
You can try activating that workbook after you set ExcelApp.ScreenUpdating = True.
Also note that ExcelApp.Workbooks.Add() creates two COM objects; both of them aren't released in your code. Your add-in may cause Excel hang in processes if the user or an application starts it programmatically. I strongly suggest that you check https://www.add-in-express.com/creating-addins-blog/2011/11/04/why-doesnt-excel-quit/.
Andrei Smolin
Add-in Express Team Leader |
|
Albert Siagian
Guest
|
Hello Andrei,
Thanks for your reply. Activating Workbook after ScrenUpdating = True is the solution I am avoiding for, if possible, but looks like that is the only solution.
Also thanks for the advise regarding releasing COM objects, will check it out.
Regards
Albert |
|
Andrei Smolin
Add-in Express team
Posts: 19138
Joined: 2006-05-11
|
You are welcome.
Andrei Smolin
Add-in Express Team Leader |
|