Closing Excel files while exiting Word

C

colt

Recently i received great help closing excel files while exiting excel. I now
needto be able to close excel files as I exit word. I have been given the
following code :

Private Sub Document_Close()

Dim pobjApp As Object
Do
On Error Resume Next
Set pobjApp = GetObject(, "Excel.Application")

On Error GoTo 0
If pobjApp Is Nothing Then
Exit Do
End If
Do Until pobjApp.Workbooks.Count = 0

'What goes here?
'I think I've tried everything?

Loop
pobjApp.Quit
Set pobjApp = Nothing
Loop
End Sub

thanks in anticipation
colt
 
J

Jezebel

Do Until pobjApp.Workbooks.Count = 0
pobjApp.Workbooks(1).Close SaveChanges:=False
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top