ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto_Open Check date and Close (https://www.excelbanter.com/excel-programming/273388-re-auto_open-check-date-close.html)

Tom Ogilvy

Auto_Open Check date and Close
 
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 8/1/2003 by DLS-Get Name on Open
'Sub Macro1()
Sub Auto_Open()
If Now Worksheets("data").Range("f10") Then
Application.Displayalerts = False
ThisWorkbook.Save '(I just added this to save without asking)
Application.Quit (This is what's not working)
End If
Call Macro2
End Sub

Quiting Excel will close the workbook - so you don't need to do it
explicitly.
as soon as you close the workbook, you macro stops executing - that is why
the application.quit was not working.

Of course, closing excel could screw up other workbooks the user has open.

--
Regards,
Tom Ogilvy


<DLS wrote in message ...


DLS

Thanks John, Here is the code I have on autoopen. The application.Quit
does not work. Maybe I didn't add it correctly. I like your extra code
regarding hiding sheets. I'm going to study it and maybe that will be a
better way to go or an addition to the following code. By the way, the
audience is real estate agents and 99% of them would have no clue how to
defeat the protection, but one percent might.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 8/1/2003 by DLS-Get Name on Open
'Sub Macro1()
Sub Auto_Open()
If Now Worksheets("data").Range("f10") Then
ThisWorkbook.Close
Application.Save (I just added this to save without asking)
Application.Quit (This is what's not working)
End If
Call Macro2
End Sub
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 7/30/2003 by DLS
'Sub GetInput()
Dim MyInput 'This line of code is optional
MyInput = InputBox("Enter Company Name")
Range("data!f2").Value = MyInput
MyInput = InputBox("Enter your Name")
Range("data!f1").Value = MyInput
MsgBox ("Hello ") & MyInput
End Sub

Thanks for your help
DLS

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 11:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com