Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Closing an open workbook

Trying to close an open workbook that is not the active workbook. It was
opened for reference as a looked but after I obtain the information I need I
want to close it.

'working file
myFileName = Application.GetOpenFilename("Text Files, *.txt")

'refernce file
VMM_FileName = Application.GetOpenFilename("Text Files, *.txt")

code here...

'close reference file
Workbooks(VMM_FileName).Activate
ActiveWorkbook.Close False

With this I get Run-time error '9': Subscript out of range

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Closing an open workbook

Try this

'working file
myFileName = Application.GetOpenFilename("Text Files, *.txt")

'refernce file
VMM_FileName = Application.GetOpenFilename("Text Files, *.txt")
Set VMM_WB = Worksbooks.open(VMM_Filename)

code here...

'close reference file
VMM_WB.Close False


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Dan" wrote in message
...
Trying to close an open workbook that is not the active workbook. It was
opened for reference as a looked but after I obtain the information I need

I
want to close it.

'working file
myFileName = Application.GetOpenFilename("Text Files, *.txt")

'refernce file
VMM_FileName = Application.GetOpenFilename("Text Files, *.txt")

code here...

'close reference file
Workbooks(VMM_FileName).Activate
ActiveWorkbook.Close False

With this I get Run-time error '9': Subscript out of range

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Closing an open workbook

For some reason thie created an error. When I changed it to

Set VMM_Workbook = ActiveWorkbook
.....
VMM_Workbook.Activate
ActiveWorkbook.Close False

This worked. Thanks

"Bob Phillips" wrote:

Try this

'working file
myFileName = Application.GetOpenFilename("Text Files, *.txt")

'refernce file
VMM_FileName = Application.GetOpenFilename("Text Files, *.txt")
Set VMM_WB = Worksbooks.open(VMM_Filename)

code here...

'close reference file
VMM_WB.Close False


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Dan" wrote in message
...
Trying to close an open workbook that is not the active workbook. It was
opened for reference as a looked but after I obtain the information I need

I
want to close it.

'working file
myFileName = Application.GetOpenFilename("Text Files, *.txt")

'refernce file
VMM_FileName = Application.GetOpenFilename("Text Files, *.txt")

code here...

'close reference file
Workbooks(VMM_FileName).Activate
ActiveWorkbook.Close False

With this I get Run-time error '9': Subscript out of range

Thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Closing an open workbook

In my example it was VMM_WB not VMM_Workbook. Did you use that throughout,
and declare it as type Workbook?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Dan" wrote in message
...
For some reason thie created an error. When I changed it to

Set VMM_Workbook = ActiveWorkbook
....
VMM_Workbook.Activate
ActiveWorkbook.Close False

This worked. Thanks

"Bob Phillips" wrote:

Try this

'working file
myFileName = Application.GetOpenFilename("Text Files, *.txt")

'refernce file
VMM_FileName = Application.GetOpenFilename("Text Files, *.txt")
Set VMM_WB = Worksbooks.open(VMM_Filename)

code here...

'close reference file
VMM_WB.Close False


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Dan" wrote in message
...
Trying to close an open workbook that is not the active workbook. It

was
opened for reference as a looked but after I obtain the information I

need
I
want to close it.

'working file
myFileName = Application.GetOpenFilename("Text Files, *.txt")

'refernce file
VMM_FileName = Application.GetOpenFilename("Text Files, *.txt")

code here...

'close reference file
Workbooks(VMM_FileName).Activate
ActiveWorkbook.Close False

With this I get Run-time error '9': Subscript out of range

Thanks






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
how i open another sheet in the same workbook without closing? kamrul Excel Discussion (Misc queries) 2 February 14th 09 08:31 AM
Keeping program open even when closing workbook Bob Excel Discussion (Misc queries) 3 April 25th 08 07:55 PM
Closing Hidden Workbook when Active Workbook is Closed SusanK521 Excel Programming 5 September 24th 05 12:27 AM
How do I stop Excel from closing the open file each time I open a. Welsin Setting up and Configuration of Excel 3 January 8th 05 11:16 PM
closing excel after closing a workbook CWalsh[_2_] Excel Programming 3 January 21st 04 03:33 PM


All times are GMT +1. The time now is 07:11 AM.

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"