Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JB JB is offline
external usenet poster
 
Posts: 115
Default Open a workbook using a stored name

I have several workbooks (call them WB1 and WB2) that moves data to a central
workbook (call it WBMain and its name never changes). Once WB1 or WB2 has
passed their data it leaves WBMain activated. At the time WBMain was
activated the name and path for WB1 or WB2 was stored on WBMain in named
cells (WBName & WBPath). My problem, although it should not happen, if the
user closes WB1 or WB2 while in WBMain then when required to go back to WB1
or WB2 it must do so using the name and path stored on WBMain. I can't seem
to get it done.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Open a workbook using a stored name

Refer the workbooks as an object...

Dim wbBook As Workbook
'To reference a open workbook (already saved)
Set wbMain = Workbooks("WBMain.xls")

'Now where ever you are you can reference the range as
Msgbox wbMain.Sheets("Sheet1").Range("A1")

If this post helps click Yes
---------------
Jacob Skaria


"JB" wrote:

I have several workbooks (call them WB1 and WB2) that moves data to a central
workbook (call it WBMain and its name never changes). Once WB1 or WB2 has
passed their data it leaves WBMain activated. At the time WBMain was
activated the name and path for WB1 or WB2 was stored on WBMain in named
cells (WBName & WBPath). My problem, although it should not happen, if the
user closes WB1 or WB2 while in WBMain then when required to go back to WB1
or WB2 it must do so using the name and path stored on WBMain. I can't seem
to get it done.

  #3   Report Post  
Posted to microsoft.public.excel.programming
JB JB is offline
external usenet poster
 
Posts: 115
Default Open a workbook using a stored name

Not exactly what I am looking for. I want to activate WB1 or WB2 if it is
still open or re-open WB1 or WB2 if closed. I have tried this

Dim WBName as Workbook
WBName = Range(€śWBName€ť)
WBName.Activate

Just to use the workbooks saved name but I get an error message.

"Jacob Skaria" wrote:

Refer the workbooks as an object...

Dim wbBook As Workbook
'To reference a open workbook (already saved)
Set wbMain = Workbooks("WBMain.xls")

'Now where ever you are you can reference the range as
Msgbox wbMain.Sheets("Sheet1").Range("A1")

If this post helps click Yes
---------------
Jacob Skaria


"JB" wrote:

I have several workbooks (call them WB1 and WB2) that moves data to a central
workbook (call it WBMain and its name never changes). Once WB1 or WB2 has
passed their data it leaves WBMain activated. At the time WBMain was
activated the name and path for WB1 or WB2 was stored on WBMain in named
cells (WBName & WBPath). My problem, although it should not happen, if the
user closes WB1 or WB2 while in WBMain then when required to go back to WB1
or WB2 it must do so using the name and path stored on WBMain. I can't seem
to get it done.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Open a workbook using a stored name

Well, use a function as below which returns a boolean

Sub Macro1()
If IsBookOpen("filename.xls") Then
'Workbook open refer the same object
Else
'Open the workbook and refer
End If
End Sub

Function IsBookOpen(strWBName As String) As Boolean
On Error Resume Next
IsBookOpen = Not (Application.Workbooks(strWBName) Is Nothing)
End Function



If this post helps click Yes
---------------
Jacob Skaria


"JB" wrote:

Not exactly what I am looking for. I want to activate WB1 or WB2 if it is
still open or re-open WB1 or WB2 if closed. I have tried this

Dim WBName as Workbook
WBName = Range(€śWBName€ť)
WBName.Activate

Just to use the workbooks saved name but I get an error message.

"Jacob Skaria" wrote:

Refer the workbooks as an object...

Dim wbBook As Workbook
'To reference a open workbook (already saved)
Set wbMain = Workbooks("WBMain.xls")

'Now where ever you are you can reference the range as
Msgbox wbMain.Sheets("Sheet1").Range("A1")

If this post helps click Yes
---------------
Jacob Skaria


"JB" wrote:

I have several workbooks (call them WB1 and WB2) that moves data to a central
workbook (call it WBMain and its name never changes). Once WB1 or WB2 has
passed their data it leaves WBMain activated. At the time WBMain was
activated the name and path for WB1 or WB2 was stored on WBMain in named
cells (WBName & WBPath). My problem, although it should not happen, if the
user closes WB1 or WB2 while in WBMain then when required to go back to WB1
or WB2 it must do so using the name and path stored on WBMain. I can't seem
to get it done.

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
Hyperlink stored in an external workbook Tony Starr Excel Discussion (Misc queries) 1 November 14th 07 12:37 AM
Open a specific workbook...find value from other open workbook and then insert cells values in cell next to it. [email protected] Excel Programming 1 May 13th 07 01:46 PM
using a workbook to open more workbooks with filenames stored in cells [email protected] Excel Programming 5 January 16th 07 04:49 PM
Locating the directory a workbook is stored in Graham Whitehead Excel Programming 1 August 4th 06 09:47 AM
Refer to picture stored in workbook JakeyC Excel Programming 0 April 12th 06 11:24 PM


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

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

About Us

"It's about Microsoft Excel"