Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default close file macro

I need a macro that will open a file named DptBBudget.xls and close the
curent file named DptBBudget.xls. I have no problem with the file open part
using the Workbooks.Open Filename:= "DptBBudget.xls" command. I am having
a problem with the Workbooks.Close command which appears to close all the
open workbooks including the one I just opened.

Any help would be appreciated. I actually have a string of about 20
document I need to open, one just behind the other so figuring this out
would be very helpful. As I suspect you have figured out, I am not a
programmer (I am an accountant) and any help would be greatly appreciated.

Thanks, Will
Will Fleenor


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default close file macro

Hi will

Use set in your code

Sub test()
Dim WB As Workbook
Set WB = Workbooks.Open("C\test.xls")
MsgBox "By"
WB.Close True ' false = not save and true = save
End Sub

Or if the workbook is active use this line

ActiveWorkbook.Close True ' false = not save and true = save


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Will Fleenor" wrote in message ...
I need a macro that will open a file named DptBBudget.xls and close the curent file named DptBBudget.xls. I have no problem with
the file open part using the Workbooks.Open Filename:= "DptBBudget.xls" command. I am having a problem with the Workbooks.Close
command which appears to close all the open workbooks including the one I just opened.

Any help would be appreciated. I actually have a string of about 20 document I need to open, one just behind the other so
figuring this out would be very helpful. As I suspect you have figured out, I am not a programmer (I am an accountant) and any
help would be greatly appreciated.

Thanks, Will
Will Fleenor



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default close file macro

You can't have two workbooks open with the same name, so it is unclear how
you are not having trouble with Workbooks.Open.

While Open is qualified by Workbooks, close is qualified by a specific
workbook (unless you wanted to close all workbooks which it appears you
don't)

Workbooks("DptBBudget.xls").Close

would just close DptBBudget.xls

--
Regards,
Tom Ogilvy


"Will Fleenor" wrote in message
...
I need a macro that will open a file named DptBBudget.xls and close the
curent file named DptBBudget.xls. I have no problem with the file open

part
using the Workbooks.Open Filename:= "DptBBudget.xls" command. I am

having
a problem with the Workbooks.Close command which appears to close all the
open workbooks including the one I just opened.

Any help would be appreciated. I actually have a string of about 20
document I need to open, one just behind the other so figuring this out
would be very helpful. As I suspect you have figured out, I am not a
programmer (I am an accountant) and any help would be greatly appreciated.

Thanks, Will
Will Fleenor




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default close file macro

You didn't specify which book to close, so your statement closes all of them.

Workbooks("DptBBudget.xls").Close

See Help for the Close method for more information if you need it.

On Thu, 21 Oct 2004 12:05:39 -0400, "Will Fleenor" wrote:

I need a macro that will open a file named DptBBudget.xls and close the
curent file named DptBBudget.xls. I have no problem with the file open part
using the Workbooks.Open Filename:= "DptBBudget.xls" command. I am having
a problem with the Workbooks.Close command which appears to close all the
open workbooks including the one I just opened.

Any help would be appreciated. I actually have a string of about 20
document I need to open, one just behind the other so figuring this out
would be very helpful. As I suspect you have figured out, I am not a
programmer (I am an accountant) and any help would be greatly appreciated.

Thanks, Will
Will Fleenor


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
Using Macro to Close Word File dwake Excel Discussion (Misc queries) 3 December 3rd 09 02:04 AM
Macro to save and close, then copy file NewSysAdmin Excel Discussion (Misc queries) 2 December 2nd 09 03:24 PM
How to close a excel file using Macro coding? Eric Excel Worksheet Functions 5 June 11th 07 03:02 PM
Macro to Open, then Close another File HROBERTSON Excel Discussion (Misc queries) 1 January 8th 07 06:41 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 06:53 AM.

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"