Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL As Long = 1
'Magellan DDE application information
Private Const DDEApplication = "Magellan"
Private Const DDETopic1 = "LocalVariable"
Private Const DDEItem1 = "EARLY"
Private Sub Form_Load()
Dim lActiveHwnd As Long, lMinimized As Long, lForeGround As Long, iCounter As Integer, lhwnd As Long
Dim lpclass As String * 256, lnkTopic As String, TermCode As String, ConvertedCode As String
Dim nlength As Integer, vk As Integer, scan As Integer, oemchar As String, dl As Long, nCheckBox As Integer
On Error GoTo errMe
lActiveHwnd = GetDesktopWindow 'first gets the desktop handle
lActiveHwnd = GetWindow(lActiveHwnd, GW_CHILD) 'look for the first child
Do Until lActiveHwnd = 0
'' now get the window text and match against the Const AppName. If a match is found then exit do. If not the do will exit.
lpclass = Space(256)
lhwnd = GetWindowText(lActiveHwnd, lpclass, 255)
If Trim(Left(lpclass, Len(SendKeyAppName))) = SendKeyAppName Then
Exit Do
End If
lActiveHwnd = GetWindow(lActiveHwnd, GW_HWNDNEXT)
Loop
' 'If a window is found
If lActiveHwnd <> 0 Then
'Get the @ACCOUNT information from Magellan
txtacct.LinkMode = vbLinkNone
txtacct.LinkTopic = DDEApplication & "|" & DDETopic1
txtacct.LinkItem = DDEItem1
txtacct.LinkMode = vbLinkManual
txtacct.LinkRequest
Dim strURL As String
strURL = "https://uat.earlyresolution.net/EarlyResolution/jsp/Main.jsp?SESS_NBR_MRTG=" & txtacct.Text & "&SESS_CURR_EVENT=0&SESS_CURR_SCR_ID=13456&SESS_CURR_SCR_ID_IMMUTABLE=13456"
ShellExecute Me.hwnd, "Open", strURL, vbNullString, "C:\", SW_SHOWNORMAL
End
Else
MsgBox "No window named that starts with" & SendKeyAppName
End
End If
errMe:
MsgBox "The Following error has occurred, Please advise system administrator" & Err.Description, vbInformation, "ACCTLKUP"
End
End Sub