PDA

View Full Version : Run time 424 object required



Me00550
07-24-2019, 11:14 AM
can someone please tell me why i am getting an error with this code and how to fix it?
Run time 424 object required


Sub but()strTitle = ""
strText = "Would you like to enter another unit"
Set YesNo = WScript.CreateObject("WScript.Shell")
intType = vbYesNo
Set YesNo = WScript.CreateObject("WScript.Shell")
intResult = YesNo.Popup(strText, 3, strTitle, intType)
Select Case intResult


Case vbYes
Sheet1.Select
Case vbNo
WScript.Echo "You clicked ""No""!"
End Select
End Sub

Paul_Hossler
07-24-2019, 11:39 AM
VBA or VBScript?

VBA I'd use MsgBox



Option Explicit


Sub but()
Dim strTitle As String, strText As String
Dim intResult As VbMsgBoxResult

strTitle = ""
strText = "Would you like to enter another unit"
intResult = MsgBox(strText, vbQuestion + vbYesNo, strTitle)

Select Case intResult
Case vbYes
Sheet1.Select
Case vbNo
MsgBox "You clicked ""No""!", vbInformation + vbOKOnly, strTitle
End Select
End Sub

Me00550
07-24-2019, 11:50 AM
i need it to be VBscript to timeout the window in instance the user forget to click a button

Me00550
07-24-2019, 12:04 PM
i figured it out


come to realize it didnt like the WScript.CreateObject("WScript.Shell") had to change it to CreateObject("WScript.Shell")

Paul_Hossler
07-24-2019, 01:14 PM
i need it to be VBscript to timeout the window in instance the user forget to click a button

FWIW I've found the pop up timeout to be unreliable

One of many articles

https://stackoverflow.com/questions/31141775/infobox-popup-refuses-to-close-on-timer-expiration