countingapples
Board Regular
- Joined
- Feb 20, 2003
- Messages
- 243
I would like to change a workbook_open event to one that automatically runs when excel is first started. Everything works as I have it now, I just can't figure out how to do the modifications. Code as I have it follows.
ThisWorkbook:
EventClass:
Practice1 (regular module):
UserForm1:
The purpose of this exercise is a practical joke on our departmental joker. Everyone is in on it, and I'm the one creating this.
Ideally, we would like to have this erase itself after running. Where the specific time to run is located, I want to change that to run for 3 minutes upon excel starting. I think I need a DateAdd function but am uncertain what to put for the starting date portion of the syntax.
Any help would be greatly appreciated.
ThisWorkbook:
Code:
Option Explicit
Dim AppClass As New EventClass
Private Sub Workbook_Open()
Set AppClass.App = Application
End Sub
EventClass:
Code:
Public WithEvents App As Application
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
Call ShowQuote
End Sub
Practice1 (regular module):
Code:
Dim dateStartTime As Date, dateEndTime As Date
Sub ShowQuote()
dateStartTime = #2:52:00 PM#
dateEndTime = #2:53:00 PM#
If Time >= dateStartTime Then
Do Until Time >= dateEndTime
UserForm1.Show
Loop
End If
If Time < dateStartTime Then
'UserForm1.Hide
MsgBox "Can I stay here and train with you Mr. PoPo?"
End If
If Time > dateEndTime Then
MsgBox " It works!!"
End If
End Sub
UserForm1:
Code:
Private Sub OKButton_Click()
'Unload Me
End Sub
Private Sub UserForm_Activate()
Dim Quote As String
Quote = " Abandon hope all ye who enter here"
lblNow.Caption = Quote
End Sub
The purpose of this exercise is a practical joke on our departmental joker. Everyone is in on it, and I'm the one creating this.
Ideally, we would like to have this erase itself after running. Where the specific time to run is located, I want to change that to run for 3 minutes upon excel starting. I think I need a DateAdd function but am uncertain what to put for the starting date portion of the syntax.
Any help would be greatly appreciated.