Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to Close a specific workbook. | Excel Discussion (Misc queries) | |||
keystroke to close active workbook window | Excel Worksheet Functions | |||
determine the active workbook containing a specific sheet | Excel Programming | |||
Excel VBA-How to close all open workbooks except one specific? | Excel Programming | |||
Mailing Excel workbooks that are not active workbook | Excel Programming |