ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   close file macro (https://www.excelbanter.com/excel-programming/334712-close-file-macro.html)

Tizy

close file macro
 

Hi
:confused: I could use a little help. I want to make a macro that
will close a file if it is opened between two times (6 am and 7 am)?
Any suggestions would be appreciated.


--
Tizy
------------------------------------------------------------------------
Tizy's Profile: http://www.excelforum.com/member.php...o&userid=25275
View this thread: http://www.excelforum.com/showthread...hreadid=387678


JMB

close file macro
 
Maybe something like this? Paste into the ThisWorkBook module in VBA. Also,
would like to point out that the file could still be opened by holding the
SHIFT key while opening the file (which prevents auto open macros from
running).

Private Sub Workbook_Open()
Const BeginTime = #6:00:00 AM#
Const EndTime = #7:00:00 AM#

If Time BeginTime And Time < EndTime Then _
Me.Close

End Sub


"Tizy" wrote:


Hi
:confused: I could use a little help. I want to make a macro that
will close a file if it is opened between two times (6 am and 7 am)?
Any suggestions would be appreciated.


--
Tizy
------------------------------------------------------------------------
Tizy's Profile: http://www.excelforum.com/member.php...o&userid=25275
View this thread: http://www.excelforum.com/showthread...hreadid=387678



Tizy[_2_]

close file macro
 

JMB

I just read your reply, it sounds good i will do it.

thank you


--
Tizy
------------------------------------------------------------------------
Tizy's Profile: http://www.excelforum.com/member.php...o&userid=25275
View this thread: http://www.excelforum.com/showthread...hreadid=387678



All times are GMT +1. The time now is 10:48 PM.

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