Error al crear el objeto InternetExplorer.Application

Error al crear el objeto InternetExplorer.Application

Postby Enrrique Vertiz » Sat Sep 25, 2021 3:46 am

Saludos estimados

Tengo un problema al invocar a IE, unas veces funciona y en otras no, alguien me puede sugerir una alternativa, estoy invocando una APP WEB que hace un proceso y devuelve un resultado, actualmente lo hago asi:

clicksing:="www.appweb.com"
TRY
oIE:=CreateObject("InternetExplorer.Application") // Primer intento
CATCH
MsgWait("Error al crear el componente InternetExplorer.Application 1","Error al firmar, reintentando",2) // AQUI tengo el problema, a veces sale, a veces NO
retu .f.
END

WITH OBJECT oIE
:Visible := .F.
:ToolBar := .F.
:FullScreen := .F.
:Invoke( "Navigate", cURL )
END WITH

TRY
oIE:Navigate2( clinkSing )
CATCH oErr1
TRY
oIE:Navigate( clinkSing )
CATCH oErr2
MsgWait("Error al tratar de firmar documento","No firmo",2)
retu .f.
END
END

HB_IDLESLEEP( 1 )
nPos:=0
WHILE oIE:ReadyState <> 4 .AND. nPos<20
HB_IDLESLEEP( 1 )
nPos++
END
IF nPos>=20
MsgStop("Tiempo de espera superado")
RETURN NIL
ENDIF
oIe:Visible:=.F.

cTextoHTML:=oIE:Document:body:innerHTML()

cRpta:=subs(cTextoHTML,AT("{respuest:",cTextoHTML)+10,1 )

if cRpta=="1"
MsgStop("No existe el archivo que se quiere procesar : "+cValFil,gci_msgerror())
else
MsgWait("Se proceso correctamente el archivo",gci_msgalert(),3)
end if
oIE:quit()
retu .t.
Enrrique Vertiz Pitta
Lima-Peru
xHb 1.23.1026X, Fwh 23.04, MySQL 8.0.X, SQLLIB 1.9m, SQLRDD
Enrrique Vertiz
 
Posts: 514
Joined: Fri Oct 07, 2005 2:17 pm
Location: Lima - Peru

Re: Error al crear el objeto InternetExplorer.Application

Postby Antonio Linares » Sat Sep 25, 2021 8:44 am

Enrique,

Prueba a llamar a SysRefresh() en vez de llamar a HB_IDLESLEEP()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Error al crear el objeto InternetExplorer.Application

Postby karinha » Sat Sep 25, 2021 1:18 pm

Complete, porfa:

Error: Unresolved external '_HB_FUN_GCI_MSGERROR' referenced from
Error: Unresolved external '_HB_FUN_GCI_MSGALERT' referenced from

Code: Select all  Expand view

// \SAMPLES\VERTIZ3.PRG

#Include "FiveWin.ch"

FUNCTION Main()

   LOCAL cLinkSing, oIE, nPos, cTextoHTML, cRpta, CURL, OERR1, OERR2, CVALFIL

   cLinkSing := ( "www.appweb.com" )

   CURL      := cLinkSing  // es esto?

   TRY

      oIE := CreateObject( "InternetExplorer.Application" ) // Primer intento

   CATCH

      MsgWait( "Error al crear el componente Internet", ;
               "Error al firmar, reintentando        ", 2 ) // AQUI tengo el problema, a veces sale, a veces NO

      RETURN( .F. )

   END

   WITH OBJECT oIE

      :Visible := .F.
      :ToolBar := .F.
      :FullScreen := .F.
      :Invoke( "Navigate", cURL ) //??? donde esta?

   END WITH

   TRY

      oIE:Navigate2( cLinkSing )     // el correcto es asi

   CATCH oErr1

   TRY

      oIE:Navigate( cLinkSing )

      CATCH oErr2

         MsgWait("Error al tratar de firmar documento","No firmo",2)

         RETURN( .F. )

      END

   END

   // HB_IDLESLEEP( 1 ) // ?? Motivo??

   nPos := 0

   WHILE oIE:ReadyState <> 4 .AND. nPos<20

      // HB_IDLESLEEP( 1 ) //??? Motivo de usar este comando?
      SYSREFRESH()

      SysWait( 0.1 )

      nPos++

   ENDDO

   IF nPos>=20

      MsgStop("Tiempo de espera superado")

      RETURN NIL

   ENDIF

   oIe:Visible:=.F.

   cTextoHTML := oIE:Document:body:innerHTML()

   cRpta := SUBST( cTextoHTML, AT( "{respuest:", cTextoHTML ) +10, 1 )

   IF cRpta=="1"

      MsgStop("No existe el archivo que se quiere procesar : "+cValFil, gci_msgerror())

   ELSE

      MsgWait("Se proceso correctamente el archivo",gci_msgalert(),3)

   ENDIF

   oIE:Quit()

RETURN( .T. )
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Error al crear el objeto InternetExplorer.Application

Postby Enrrique Vertiz » Sat Sep 25, 2021 2:10 pm

Gracias Antonio / Karinha

Probando
Enrrique Vertiz Pitta
Lima-Peru
xHb 1.23.1026X, Fwh 23.04, MySQL 8.0.X, SQLLIB 1.9m, SQLRDD
Enrrique Vertiz
 
Posts: 514
Joined: Fri Oct 07, 2005 2:17 pm
Location: Lima - Peru


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 85 guests