Pop-up box with no 'okay' buttons

F

ForSale

Private Sub Workbook_BeforeClose(CANCEL As Boolean)

Dim cTime As Long
Dim WSH As Object

Set WSH = CreateObject("WScript.Shell")
cTime = 1 ' 1 secs
Select Case WSH.Popup("Last Updated By" & Application.UserName, cTime
"Closing", vbOKOnly)
End Select

Call macro1

End Sub

this pops up a box that says last updated by & username, then goes awa
after 1 second. the only thing that i would change about it, is tha
it has an 'okay' button on it. is it possible to have no buttons
 
K

K Dales

You could do this more simply with a UserForm - design one
with a TextBox (here called TextBox1) and set the
ShowModal Property to False; then you can use this code:

Private Sub Workbook_BeforeClose(CANCEL As Boolean)

Dim StartTime As Date

UserForm1.TextBox1.Value = "Last Updated By " &
Application.UserName

StartTime = Now

UserForm1.Show

While StartTime > (Now - TimeValue("00:00:10"))
DoEvents
Wend

UserForm1.Hide

End Sub
 
F

ForSale

Thanks,
that works good, however, it doesn't seem to go away on it's own.
changed the 00:00:10 to 00:00:01 and it didn't ever get to th
userform.hide
any suggestions
 
K

K Dales

Don't know why it isn't getting to UserForm.Hide. Are you
sure you have the While loop set up properly, with a
DoEvents inside it? And that the UserForm's Modal
property is False? Those would be the most likely things
to cause problems. The code I sent worked on my machine
as written - was a cut and paste; I am using Excel 2000.
 
F

ForSale

i'm on XP professional. here is the code in question:

Public Sub UserFormClose()

Dim StartTime As Date

UserForm3.Label1.Caption = "Last Updated By " & Application.UserName

StartTime = Now

UserForm3.Show

While StartTime > (Now - TimeValue("00:00:01"))
DoEvents
Wend

UserForm3.Hide

End Sub

still not getting to the hide line.

thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top