Results 1 to 1 of 1

Thread: Web timeout

  1. #1

    Thread Starter
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Web timeout

    Hello,

    I am trying to translate a text in excel using googleapis.

    When I type the URL:

    "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=Text+to+translate&langpair=en%7Cpt"

    directly in the browser I get a text response:

    {"responseData": {"translatedText":"Texto para traduzir"}, "responseDetails": null, "responseStatus": 200}

    which has the translated text in it.

    Now I am trying to automate this in Excel. How can I send the URL and catch the response? This is part of the code I have but when it gets to objHTTP.Send, it waits until the timeout and fails. Any idea?

    vb.net Code:
    1. Function fTranslate() As String
    2.  
    3.     Dim objHTTP As Object
    4.     Dim URL As String
    5.    
    6.     Set objHTTP = CreateObject("Msxml2.ServerXMLHTTP.3.0")
    7.    
    8.     URL = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=Text+to+translate&langpair=en%7Cpt"
    9.  
    10.     objHTTP.Open "GET", URL, False
    11.     objHTTP.setTimeouts 100000, 100000, 100000, 100000
    12.     objHTTP.send ("")
    13.  
    14.     fTranslate = objHTTP.ResponseText
    15.  
    16. End Function
    Last edited by kaliman79912; Apr 25th, 2011 at 04:29 PM. Reason: decided to post the whole function
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width