Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controling IE with VBA

Status
Not open for further replies.

Gandalph067

Programmer
Nov 28, 2012
9
US
Good Afternoon,


I am attempting to control commands sent to our paging system and I am getting an automation error message I cannot seem to get around. The code will create the IE object, open an explorer window where I get the acknowledge back in the from the explorer. In the address line is the command, then on the frame/Main window !sc1, which is the reponse of message recieved by the pager. The pager will buzz and display the message. When in the code it runs the next line "Do while ie.Busy and not.." I get the Run-Time error '-2147417848(80010108)': Automation error the object invoked has disconneted from its clients.

I can run the same code for a Bing search window without issue, it has to be something with the address I am navigating to send the message. I would love to use winsocket for this simple send and reciceve the message back but I am at a loss when trying to get this to work. Any and all suggestions would be greatly appreciate, I am running out of hair to pull

respectfully,

M

Sub Demo()
Dim ie As Object, strMessage As String
Set ie = CreateObject("internetexplorer.application")
strMessage = Forms!frmsend!txtMessage
ie.navigate " & intPager & "&type=2&msg=" & strMessage & "&baud=1&beep=1"

Do While ie.Busy And Not ie.ReadyState = 4
DoEvents
Loop
ie.Visible = True

ie.Quit
 
Good Afternoon!

After many frustrating hours I had a Gentleman help me understand some fo the issues the command I was using and suggested a change in direction which was able to solve the above issue. instead of a HTTP command he used a XML commands to do virtually the same thing. I guess I had looked at this and did not realize I was staring at the answer, too close to the project. I add the code to the post in case others run into something like this

Set XMLHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
XMLHTTP.Open "POST", " & intPager & "&type=2&msg=" & strMessage & "&baud=1&beep=1" 'False
XMLHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
XMLHTTP.setRequestHeader "Content-type", "application/x-XMLHTTP.send argumentString
result = XMLHTTP.responsetext
Set XMLHTTP = Nothing

Cheers,

M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top