I've looked at Use HTML tags in VBScript and How can I call a vbscript function from html?, but I can't see what is wrong with my code. Can someone look it over and let me know why, when I click the OK button, the window doesn't close? I commented some lines out that I've tried and didn't work.
Dim objIE, objShell
Dim strDX
Set objIE = CreateObject("InternetExplorer.Application")
Set objShell = CreateObject("WScript.Shell")
strDX = "AT-0125B"
objIE.Navigate "about:blank"
objIE.Document.Title = "Covered Diagnosis"
objIE.ToolBar = False
objIE.Resizable = False
objIE.StatusBar = False
objIE.Width = 350
objIE.Height = 200
'objIE.Scrollbars="no"
' Center the Window on the screen
With objIE.Document.ParentWindow.Screen
objIE.Left = (.AvailWidth - objIE.Width ) \ 2
objIE.Top = (.Availheight - objIE.Height) \ 2
End With
objIE.document.body.innerHTML = "<b>" & strDX & " is a covered diagnosis code.</b><p> </p>" & _
"<center><input type='submit' value='OK' onclick='VBScript:ClickedOk()'></center>" & _
"<input type='hidden' id='OK' name='OK' value='0'>"
objIE.Visible = True
'objShell.AppActivate "Covered Diagnosis"
'MsgBox objIE.Document.All.OK.Value
Function ClickedOk
'If objIE.Document.All.OK.Value = 1 Then
'objIE.Document.All.OK.Value = 0
'objShell.AppActivate "Covered Diagnosis"
'objIE.Quit
Window.Close()
'End If
End Function
iftest fails, and window.close() never gets called.iftest, so it can test the "live" value as changed by the form, not the value that exists at the time you're defining the html.VBScript:, so you're trying to call an undefined javascript function.