LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Closing one workbook with a varying name

Hi,

I'm trying to close one specific workbook that I've opened with the
Workbooks.Add command. This causes the workbook to come up with a name
that changes (book1, book2, etc.). After the rest of the code has
finished, I want to close this one workbook, leaving all other active
workbooks open. I've been trying to work with Workbooks.Close but that
keeps closing all workbooks. So the next thing I tried went like this.

Sub OpenandClose()
Dim wB as String
wB = "WorkBook"
Workbooks(wB).Add
'rest of code
Workbooks(wB).close
End Sub

But that's not working either - getting error 9, subscript out of range
on Workbooks(wB).Add

Any thoughts? Thanks in advance for any help.

 
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
Closing Hidden Workbook when Active Workbook is Closed SusanK521 Excel Programming 5 September 24th 05 12:27 AM
Help with closing down a workbook?? Don Excel Worksheet Functions 1 May 9th 05 04:05 AM
Closing a workbook... Jeff Harbin[_2_] Excel Programming 2 August 11th 04 01:52 AM
closing excel after closing a workbook CWalsh[_2_] Excel Programming 3 January 21st 04 03:33 PM
displaying varying toolbars depending on workbook Rich[_13_] Excel Programming 0 July 30th 03 11:26 PM


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