Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default If open, go to, else open

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default If open, go to, else open

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default If open, go to, else open

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default If open, go to, else open

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   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default If open, go to, else open

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ON OPEN VBA Code input incorrectly now excel sheet wont open mmartin New Users to Excel 1 February 16th 11 11:33 PM
Opening Excel, Book1 opens, remains open with other workbook open DanieB Excel Discussion (Misc queries) 0 September 3rd 09 08:23 AM
excel 2003 saved file will not open without a blank workbook open Bob Excel Discussion (Misc queries) 4 November 11th 06 04:24 PM
Open email windows can't open, excel shreadsheet file .xls ? skiz Excel Discussion (Misc queries) 0 October 2nd 05 07:03 PM
file open via IE hyperlink causes already open files to shrink and tile Marc Setting up and Configuration of Excel 0 May 4th 05 08:13 PM


All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"