ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   To open workbooks: how to put behind wbk in front? (https://www.excelbanter.com/excel-programming/429846-re-open-workbooks-how-put-behind-wbk-front.html)

Dave Peterson

To open workbooks: how to put behind wbk in front?
 
So you want to just activate the workbook (or window) that was active before
your code started?

Dim ActWkbk as workbook
set actwkbk = nothing
on error resume next
set actwkbk = activeworkbook
on error goto 0

'your code here

if actwkbk is nothing then
'nothing was active when you started
else
actwkbk.activate
end if



fred wrote:

That can be the problem.
If the workbook is already opened before my app starts I will not know its
name.
Thanks,
Fred

"Dave Peterson" wrote in message
...
If you know the name of the workbook being opened:
Workbooks("book999.xls").activate


fred wrote:

Hello,
My app opens 2 workbooks using Excel automation.
The second wrkbook is displayed in front.
How to put the first wrkbook in front?
Thanks,
Fred


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 05:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com