Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Close a Excel Workbook when close a userform in Outlook (http://www.outlookbanter.com/outlook-vba/71631-close-excel-workbook-when-close.html)

[email protected] May 8th 08 01:00 PM

Close a Excel Workbook when close a userform in Outlook
 


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
Set objXL = GetObject(, "Excel.Application")

x = objXL.Workbooks.Application.ActiveWorkbook.Name

If x = "Prosjekt.xls" Then
objXL.x.Close savechanges:=True ' ?????????
End If

End Sub

Need help!

Ken Slovak - [MVP - Outlook] May 8th 08 02:21 PM

Close a Excel Workbook when close a userform in Outlook
 
You are trying to call the Close method on the Name property of the
workbook. Try getting the workbook as an object and calling its Close
method.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


wrote in message
...


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
Set objXL = GetObject(, "Excel.Application")

x = objXL.Workbooks.Application.ActiveWorkbook.Name

If x = "Prosjekt.xls" Then
objXL.x.Close savechanges:=True ' ?????????
End If

End Sub

Need help!



[email protected] May 8th 08 02:54 PM

Close a Excel Workbook when close a userform in Outlook
 
Thanks, this works:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)

Dim XLObject As Object
Set XLObject = GetObject("H:\Outlook\Prosjekt.xls")
XLObject.Close SaveChanges:=True

End Sub


All times are GMT +1. The time now is 03:36 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com