One button to open and re-select

G

Gee...

I don't have any trouble opening or activating or
selecting...it's just getting it to happen with the same
button that's causing me grief.
Anyone else have any ideas?
Thank you,
Gee...

I have the following for some buttons.
To open I have:
Workbooks.Open Filename:=
"\\bo-10\ToP\ToP Bark\PI\aPM\PMP.xls"

I then have another button to go back to that sheet if
it's already open.
Windows("PMP.xls").Activate
I need to know what the "IF" statement is so I don't
have to have 2 buttons.

How do I say:
If "\\bo-10\ToP\ToP Bark\PI\aPM\PMP.xls" is open,
activate "PMP.xls", else open "\\bo-10
\ToP\ToPBark\PI\aPM\PMP.xls"

I keep trying to do it and getting it wrong.
Help?
Thank you,
Gee
 
F

Frank Kabel

Hi
I already posted a solution for this :)
Have you tried it?

Try a code like the following (assigned to ONE button)

...
dim wbk as workbook
on error resume next
set wbk = workbooks("PMP.xls")
on error goto 0
if wbk is nothing then
Workbooks.Open Filename:=
"\\bo-10\ToP\ToP Bark\PI\aPM\PMP.xls"
set wbk = activeworkbook
end if
wbk.activate
....
 
G

Guest

Yep, I tried it and it opens it the first time ok, but
when I go to another workbook, then back to
my "switchboard", where all the buttons are, then try to
go to PMP.xls again, it tells me it's already open
and "Reopening will cause any changes you made to be
discarded...etc."
 
F

Frank Kabel

Hi
just tried the code again (and it worked in my environment). Could you
please post your complete used code which showed this behaviour
 
G

Gee...

OK...I did something wrong...it is working now. Thank you
so much for your patience!
Gee...
 
Top