A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Close a Excel Workbook when close a userform in Outlook



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 8th 08, 01:00 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 3
Default 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!
  #2  
Old May 8th 08, 02:21 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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!


  #3  
Old May 8th 08, 02:54 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 3
Default 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
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reminder from Excel Workbook Looping through Outlook and VBA 1 February 29th 08 05:03 PM
Close Message, Close Outlook cdf Outlook - General Queries 2 April 16th 07 03:42 PM
How can I eMail only the selection from Excel, not the workbook Andre Outlook - General Queries 0 February 20th 07 07:46 PM
Build a userform on excel to copy contacts from outlook 2003 Oggy Outlook - General Queries 4 January 2nd 07 06:13 PM
Build a userform on excel to copy contacts from outlook 2003 Oggy Outlook and VBA 4 January 2nd 07 06:13 PM


All times are GMT +1. The time now is 10:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.