|
-
Feb 28th, 2002, 05:52 AM
#1
Thread Starter
New Member
Question about closing excel.
What vb-code can I put in my macro formula to close the program excel? I use this code to close the document without saving:
Application.DisplayAlerts = False
ActiveWorkbook.Close
This code only closes te document and not the whole excel program. What code can I use for that?
Thanks for replies!
Greetz Relli.
-
Feb 28th, 2002, 05:54 AM
#2
Bouncy Member
-
Feb 28th, 2002, 05:57 AM
#3
Thread Starter
New Member
It doesn't seem to work. Excel remains open.
-
Feb 28th, 2002, 05:59 AM
#4
Bouncy Member
works for me.
can you paste your code?
-
Feb 28th, 2002, 06:14 AM
#5
try:
this will close any open documents (including hidden ones) without saving them, I got that problem before when I had a hidden document open - it tried to ask to save it, but with displayalerts set to false it doesn't show the message
-
Feb 28th, 2002, 06:32 AM
#6
Thread Starter
New Member
Sub Sluiten()
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.Quit False
End Sub
-
Feb 28th, 2002, 06:36 AM
#7
Addicted Member
Do you have any references to a range object still open....I know there should be a lot of examples dealing with the exact same problem.....
We have the technology and we are not afraid to use it
-
Feb 28th, 2002, 07:54 AM
#8
Bouncy Member
that's a good point make sure any references, objects etc are destroyed first, i'm not sure what effect they have on VBA for Excel...
-
Feb 28th, 2002, 08:21 AM
#9
Thread Starter
New Member
I feel there should be a code to close excel. Just simply close, no further problems. But what the code is? Tell me......
-
Feb 28th, 2002, 08:24 AM
#10
Try this:
ActiveWorkbook.Close False
Application.Quit False
also, when testing it try it without "Application.DisplayAlerts = False", it should then hopefully tell you why it isn't closing
-
Feb 28th, 2002, 08:27 AM
#11
Thread Starter
New Member
How should I write the code? Like this?
Sub Sluiten()
'
ActiveWorkbook.Close False
Application.Quit False
'
End Sub
I am still a VB rookie.
If it ain't dutch, it ain't much.
-
Feb 28th, 2002, 08:28 AM
#12
-
Feb 28th, 2002, 08:32 AM
#13
Thread Starter
New Member
Doesn't work VB doesn't like the .quit text in the code.
If it ain't dutch, it ain't much.
-
Feb 28th, 2002, 08:35 AM
#14
Addicted Member
Hoi! Probeer dit eens
Option Explicit
Public Sub fExcel()
'excel ****
Dim objExcel As Excel.Application
Dim objWorkbook As Excel.Workbook
Dim objWorksheet As Excel.Worksheet
Dim objChart As Excel.Chart
Dim objRng As Range
Set objRng = Nothing
Set objChart = Nothing
exit_Handler:
'Free up memory, otherwise there will be a memory leak.
Set objWorksheet = Nothing
objWorkbook.Close False
Set objWorkbook = Nothing
objExcel.Quit
Set objExcel = Nothing
Exit Function
err_handler:
MsgBox Err.Description, vbInformation
Err.Number = 0
Resume exit_Handler
End Function
-
Feb 28th, 2002, 08:41 AM
#15
Thread Starter
New Member
Jihah, een mede dutchy.
Hij geeft een foutmelding:
Compileerfout:
Exit Function is niet toegestaan in Sub of Property
Ik wil dus gewoon excel afsluiten met een macro functie. In een excel-sheet dus een knop met afsluiten in plaats van op het kruisje rechtsboven te drukken.
Help? Alvast bedankt.
If it ain't dutch, it ain't much.
-
Feb 28th, 2002, 08:48 AM
#16
Bouncy Member
english???
please
-
Feb 28th, 2002, 08:50 AM
#17
Thread Starter
New Member
If it ain't dutch, it ain't much.
-
Feb 28th, 2002, 08:55 AM
#18
Addicted Member
Sorry, nog een keertje...... Foutje van mij.
Hoi! Probeer dit eens
Option Explicit
Public Sub fExcel()
'excel ****
Dim objExcel As Excel.Application
Dim objWorkbook As Excel.Workbook
Dim objWorksheet As Excel.Worksheet
Dim objChart As Excel.Chart
Dim objRng As Range
Set objRng = Nothing
Set objChart = Nothing
exit_Handler:
'Free up memory, otherwise there will be a memory leak.
Set objWorksheet = Nothing
objWorkbook.Close False
Set objWorkbook = Nothing
objExcel.Quit
Set objExcel = Nothing
Exit Sub
err_handler:
MsgBox Err.Description, vbInformation
Err.Number = 0
Resume exit_Handler
End Sub
-
Feb 28th, 2002, 08:57 AM
#19
Addicted Member
Ben je erg nieuw met programmeren?
Ik had een funktie geschreven, maar daar het jij nu even niets aan. Je kan het ook als een sub gebruiken. ff koppie-peesten
-
Feb 28th, 2002, 09:02 AM
#20
Thread Starter
New Member
Ik heb hem nu zo staan. Hij geeft echter weer een fout:
objectvariabele of blokvariabele With is niet opgesteld
Public Sub fExcel()
'excel ****
Dim objExcel As Excel.Application
Dim objWorkbook As Excel.Workbook
Dim objWorksheet As Excel.Worksheet
Dim objChart As Excel.Chart
Dim objRng As Range
Set objRng = Nothing
Set objChart = Nothing
exit_Handler:
'Free up memory, otherwise there will be a memory leak.
Set objWorksheet = Nothing
objWorkbook.Close False
Set objWorkbook = Nothing
objExcel.Quit
Set objExcel = Nothing
Exit Sub
err_handler:
MsgBox Err.Description, vbInformation
Err.Number = 0
Resume exit_Handler
End Sub
If it ain't dutch, it ain't much.
-
Feb 28th, 2002, 09:49 AM
#21
Addicted Member
Hoi, ben ik weer. Ik zie dat je macros maakt. post je code maar ff en dan kijk ik wel. Probeer in het vervolg alleen maar engelse versies van microsoft te gebruiken, want je komt geheid in de problemen.
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
|