Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Nigel
 
Posts: n/a
Default select workbook macro

Hi,
i have been struggling with a macro to select a workbook if it is open, and
open it if it is closed. the details are as follows.
workbook to be opened is S:\QUOTE REGISTER updated
( select sheet year to date )which i can do!!there is a password of babylon

if the book is closed, then it needs to be opened and sheet selected.
if the book is open, then it needs to be made active and sheet selected.

i just cannot seem to do it.

Kindest Regards,

Nigel
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default


On Error Resume Next
Set oWb = Workbooks("QUOTE REGISTER .xls")
On Error Goto 0
If oWB Is Nothing Then
Workbooks.Open filename:="S:\QUOTE REGISTER .xls"
Else
Workbooks("QUOTE REGISTER .xls").Activate
End If
Activeworkbook.Worksheets("Sheet1").Activate

--
HTH

Bob Phillips

"Nigel" wrote in message
...
Hi,
i have been struggling with a macro to select a workbook if it is open,

and
open it if it is closed. the details are as follows.
workbook to be opened is S:\QUOTE REGISTER updated
( select sheet year to date )which i can do!!there is a password of

babylon

if the book is closed, then it needs to be opened and sheet selected.
if the book is open, then it needs to be made active and sheet selected.

i just cannot seem to do it.

Kindest Regards,

Nigel



  #3   Report Post  
Nigel
 
Posts: n/a
Default

Hi Bob,
thanks for the prompt response. However this seems to error on the following
if oWB = Nothing Then

there is an error code of 424 object required.

Regards,

Nigel

"Bob Phillips" wrote:


On Error Resume Next
Set oWb = Workbooks("QUOTE REGISTER .xls")
On Error Goto 0
If oWB Is Nothing Then
Workbooks.Open filename:="S:\QUOTE REGISTER .xls"
Else
Workbooks("QUOTE REGISTER .xls").Activate
End If
Activeworkbook.Worksheets("Sheet1").Activate

--
HTH

Bob Phillips

"Nigel" wrote in message
...
Hi,
i have been struggling with a macro to select a workbook if it is open,

and
open it if it is closed. the details are as follows.
workbook to be opened is S:\QUOTE REGISTER updated
( select sheet year to date )which i can do!!there is a password of

babylon

if the book is closed, then it needs to be opened and sheet selected.
if the book is open, then it needs to be made active and sheet selected.

i just cannot seem to do it.

Kindest Regards,

Nigel




  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default

Nigel,

Precede this code with

Dim oWb As Workbook

--
HTH

Bob Phillips

"Nigel" wrote in message
...
Hi Bob,
thanks for the prompt response. However this seems to error on the

following
if oWB = Nothing Then

there is an error code of 424 object required.

Regards,

Nigel

"Bob Phillips" wrote:


On Error Resume Next
Set oWb = Workbooks("QUOTE REGISTER .xls")
On Error Goto 0
If oWB Is Nothing Then
Workbooks.Open filename:="S:\QUOTE REGISTER .xls"
Else
Workbooks("QUOTE REGISTER .xls").Activate
End If
Activeworkbook.Worksheets("Sheet1").Activate

--
HTH

Bob Phillips

"Nigel" wrote in message
...
Hi,
i have been struggling with a macro to select a workbook if it is

open,
and
open it if it is closed. the details are as follows.
workbook to be opened is S:\QUOTE REGISTER updated
( select sheet year to date )which i can do!!there is a password of

babylon

if the book is closed, then it needs to be opened and sheet selected.
if the book is open, then it needs to be made active and sheet

selected.

i just cannot seem to do it.

Kindest Regards,

Nigel






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
mag-text in merged cells-automatic row heigh 68magnolia71 Excel Worksheet Functions 10 April 9th 05 08:43 PM
run macro on workbook open kevin Excel Discussion (Misc queries) 3 March 4th 05 10:12 AM
Subscript & Superscript Karen Excel Discussion (Misc queries) 6 February 22nd 05 10:16 PM
Run macro in new workbook BobP Excel Discussion (Misc queries) 3 February 9th 05 12:19 AM
Macro for multiple charts JS Excel Worksheet Functions 1 November 19th 04 03:44 AM


All times are GMT +1. The time now is 04:11 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"