Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do check to see if a workbook's open, and if it's not already open
then open it? I've looked in the forum, but nobody seems to be looking for the abov condition. I've got this already: jbl = "Production Schedule 040512.xls" checkForBook = CBool(Len(Workbooks(jbl).name)) If Not checkForBook Then 'What goes here?' End I -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
if checkForBook = false then workbooks.open jbl -----Original Message----- How do check to see if a workbook's open, and if it's not already open, then open it? I've looked in the forum, but nobody seems to be looking for the above condition. I've got this already: jbl = "Production Schedule 040512.xls" checkForBook = CBool(Len(Workbooks(jbl).name)) If Not checkForBook Then 'What goes here?' End If --- Message posted from http://www.ExcelForum.com/ . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Umm...in addition to Wolf's suggestion, you also need an error trap.
Try something along the lines of Sub testIt() Dim JBL As String, JBLWB As Workbook JBL = "Production Schedule 040512.xls" On Error Resume Next Set JBLWB = Workbooks(JBL) On Error GoTo 0 If JBLWB Is Nothing Then Set JBLWB = Workbooks.Open(JBL) End If End Sub You still may have problems opening the workbook if the path is not correct, but that is another story. -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , scain2004 says... How do check to see if a workbook's open, and if it's not already open, then open it? I've looked in the forum, but nobody seems to be looking for the above condition. I've got this already: jbl = "Production Schedule 040512.xls" checkForBook = CBool(Len(Workbooks(jbl).name)) If Not checkForBook Then 'What goes here?' End If --- Message posted from http://www.ExcelForum.com/ |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ok, that worked, except I need the focus to remain on the callin
workbook. How should I do that? Workbooks("Production Job List - 040516.xls").Activate -- Message posted from http://www.ExcelForum.com |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
ThisWorkbook.Activate
"scain2004 " wrote in message ... Ok, that worked, except I need the focus to remain on the calling workbook. How should I do that? Workbooks("Production Job List - 040516.xls").Activate ? --- Message posted from http://www.ExcelForum.com/ |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ok, this is what I did and it works great:
cwb = "Workbook 1" jbl = ThisWorkbook.Name On Error Resume Next Set wb = Workbooks(cwb) On Error GoTo 0 If wb is Nothing Then Set wb = Workbooks.Open(cwb) End If Application.Workbooks(jbl).Activate Thanks! -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to: Open closed workbook/Search data tables/Return data to open workbook | Excel Discussion (Misc queries) | |||
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) | |||
Search open sheets in workbook and insert into open sheet | Excel Discussion (Misc queries) | |||
Excel workbook does not open in open window on desktop | Excel Discussion (Misc queries) |