how to set workbook window active

  • Thread starter Thread starter Daniel M
  • Start date Start date
D

Daniel M

I have an add in that i have installed with all my macros in it. In one of my
macros i call it to open another workbook for a vlookup. i then want to
continue with the previous workbook but i dont know how to return the focus
to that workbook.

add in: macros.xla
file opened: opened.xls (name is variable!)
call to open: master list.xls

I cant do Thisworkbook.active because i am running out of the add-in.
i cant do windows(opened.xls).active because i wont know the file name.

What can i do? Thanks.
 
I have an add in that i have installed with all my macros in it. In one of my
macros i call it to open another workbook for a vlookup. i then want to
continue with the previous workbook but i dont know how to return the focus
to that workbook.

add in: macros.xla
file opened: opened.xls (name is variable!)
call to open: master list.xls

I cant do Thisworkbook.active because i am running out of the add-in.
i cant do windows(opened.xls).active because i wont know the file name.

What can i do? Thanks.

you could store the recent workbook before opening the opened.xls
and then restore it again:
'----------------------------------------------------------
dim Curr_WB as workbook

set Curr_WB = activeworkbook

'openworkbook
'do your thing

Curr_WB.activate
'----------------------------------------------------------
hth

Carlo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top