|
-
Mar 28th, 2005, 11:07 PM
#1
Thread Starter
Lively Member
Cannot close WorkBooks ...
I tried other ways of closing it, but it is still in the Tast Manager ...
It opens it up and that's it ... how the hell do I close it
I use Microsoft Excel 11.0 Lib.
here is the code
VB Code:
Public Sub Check_Validity2()
On Error GoTo NoFile
Set myBook = Workbooks.Open(strMainFilePath)
exists = myBook.Worksheets("AH Data").Cells(1, 3).Value
If exists = "AH1 (AH09-01)" Then
exists = "true"
Else: exists = ""
End If
myBook.Close savechanges:=False
NoFile:
If Err.Number = 9 Then
myBook.Close
exists = ""
End If
End Sub
Last edited by RobDog888; Mar 28th, 2005 at 11:23 PM.
-
Mar 28th, 2005, 11:27 PM
#2
Re: Cannot close WorkBooks ...
I take it that this is entirely in Excel. So, you are wanting to close the workbook AND close Excel.
This will close the Excel application if you have already closed the workbook.
After you close the workbook you need to destroy the workbook object.
VB Code:
myBook.Close
Set mybook = Nothing
Application.Quit
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|