Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 dont' 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\ToP Bark\PI\aPM\PMP.xls" I keep trying to do it and getting it wrong. Help? Thank you, Gee |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
one way 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 -- Regards Frank Kabel Frankfurt, Germany Gee... wrote: 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 dont' 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\ToP Bark\PI\aPM\PMP.xls" I keep trying to do it and getting it wrong. Help? Thank you, Gee |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It opened it, but I got a message that is was "already
open and reopening will cause any changes you made to be discarded..." I thought there was a simple if, then statement I could use. -----Original Message----- Hi one way 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 -- Regards Frank Kabel Frankfurt, Germany Gee... wrote: 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 dont' 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\ToP Bark\PI\aPM\PMP.xls" I keep trying to do it and getting it wrong. Help? Thank you, Gee . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
the code I provided should only open the workbook if it is not already opened. Sorry, there's no simple if then statement for this -- Regards Frank Kabel Frankfurt, Germany Gee wrote: It opened it, but I got a message that is was "already open and reopening will cause any changes you made to be discarded..." I thought there was a simple if, then statement I could use. -----Original Message----- Hi one way 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 -- Regards Frank Kabel Frankfurt, Germany Gee... wrote: 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 dont' 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\ToP Bark\PI\aPM\PMP.xls" I keep trying to do it and getting it wrong. Help? Thank you, Gee . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yeah...that's what I came up with. 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... -----Original Message----- Hi the code I provided should only open the workbook if it is not already opened. Sorry, there's no simple if then statement for this -- Regards Frank Kabel Frankfurt, Germany Gee wrote: It opened it, but I got a message that is was "already open and reopening will cause any changes you made to be discarded..." I thought there was a simple if, then statement I could use. -----Original Message----- Hi one way 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 -- Regards Frank Kabel Frankfurt, Germany Gee... wrote: 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 dont' 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\ToP Bark\PI\aPM\PMP.xls" I keep trying to do it and getting it wrong. Help? Thank you, Gee . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
ON OPEN VBA Code input incorrectly now excel sheet wont open | New Users to Excel | |||
Opening Excel, Book1 opens, remains open with other workbook open | Excel Discussion (Misc queries) | |||
excel 2003 saved file will not open without a blank workbook open | Excel Discussion (Misc queries) | |||
Open email windows can't open, excel shreadsheet file .xls ? | Excel Discussion (Misc queries) | |||
file open via IE hyperlink causes already open files to shrink and tile | Setting up and Configuration of Excel |