LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bon Bon is offline
external usenet poster
 
Posts: 23
Default How to close specific workbook not all active workbooks?

Hello all

I have assign a specific workbook to the workbook variable. But, it
doesn't close the specific workbook. It closes all active workbooks.
How can I solve this problem?

My module:

Sub CopyWorksheetContentToWork(strFilePath As String)
Dim xlApp As Excel.Application
Dim xlWorkbook As Excel.Workbook
Dim WorkbookToWorkOn As String
Dim ExcelWasNotRunning As String

WorkbookToWorkOn = strFilePath

On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")

If Err Then
ExcelWasNotRunning = True
Set xlApp = CreateObject("Excel.Application")
End If

Set xlWorkbook = xlApp.Workbooks(WorkbookToWorkOn)

'Code for copying Excel worksheets content to ActiveDocument

xlApp.Visible = False
xlWorkook.Close SaveChangee:=False
xlApp.Quit
Set xlWorkbook = Nothing
Set xlApp = Nothing
End Sub

Could anyone point out my mistakes?
Thank you very much

Cheers
Bon

 
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
Macro to Close a specific workbook. Dmad11 Excel Discussion (Misc queries) 1 July 7th 09 09:28 PM
keystroke to close active workbook window Vickie Excel Worksheet Functions 4 December 7th 05 11:21 PM
determine the active workbook containing a specific sheet Valeria Excel Programming 1 September 29th 05 08:21 PM
Excel VBA-How to close all open workbooks except one specific? waveracerr[_13_] Excel Programming 3 February 13th 04 06:53 PM
Mailing Excel workbooks that are not active workbook Beverly[_3_] Excel Programming 11 January 15th 04 12:51 PM


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