Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hyperlink stored in an external workbook | Excel Discussion (Misc queries) | |||
Open a specific workbook...find value from other open workbook and then insert cells values in cell next to it. | Excel Programming | |||
using a workbook to open more workbooks with filenames stored in cells | Excel Programming | |||
Locating the directory a workbook is stored in | Excel Programming | |||
Refer to picture stored in workbook | Excel Programming |