Jump to content
Fivewin Brasil

Janela está aberta??? CreateObject("InternetExplorer.Application")


zekasan

Recommended Posts

Bom dia, alguém pode me ajudar???

Como fico sabendo se a janela aberta na rotina CreateObject("InternetExplorer.Application"), está aberta???

    oOle:= CreateObject("InternetExplorer.Application")

    oOle:Visible    := .t.
    oOle:ToolBar    := .f.
    oOle:StatusBar  := .f.
    oOle:MenuBar    := .f.

    oOle:Navigate2("https://www.sefaz.rs.gov.br/NFE/NFE-CCC.aspx")

    hWnd:=oOle:hWnd
    ShowWindow(hWnd, 1 )
    BringWindowToTop(hWnd)    

    While oOle:Busy
        syswait(.5)
    End

*   cCopiar("60157377000504")

    try
        oOle1 := oOle:Document()
        oOle1:getElementById("ctl00_cphConteudo_cmbUF"):value := "35"  // 35-> SP
        oOle1:getElementById("ctl00_cphConteudo_cmbUF"):Focus()
        oOle1:getElementById("ctl00_cphConteudo_cmbUF"):Click()
            
        oOle1:getElementById("tbxCNPJContrib"):value := QUAL_CNPJ

    catch
    end

    do while  JANELA_ABERTA????
        syswait(??)
    enddo

 

 

GRATO

Link to comment
Share on other sites

Não entendi muito bem, mas veja se ajuda.

https://imgur.com/dkfQicV

 

dkfQicV.png

 

#Include "FiveWin.ch"
#Include "hbcompat.ch"
	Function Main()
	   LOCAL cRet
	   cRet := MsgRun( "Verificando a Sefaz.", ;
                   "Por Favor, Espere!"  , ;
                   { || STRTRAN( PegaSefaz(), '*',';' ) } )
	RETURN NIL
	Function PegaSefaz()
	   Local OOLE, CDIA, CMES, CANO, CDATA, CHORA, QUAL_CNPJ
   Local cRet := "", cPagina := ""
   Local cTexto := "Local time in Brasilia"
	   IF ( oOle := Cria_OLE( "InternetExplorer.Application", , .T. ) ) == NIL
	      RETURN( .F. )
	   ENDIF
	   QUAL_CNPJ := "60157377000504"
	   oOle:Visible    := .T.
   oOle:ToolBar    := .F.
   oOle:StatusBar  := .F.
   oOle:MenuBar    := .F.
	   oOle:Navigate("https://www.sefaz.rs.gov.br/NFE/NFE-CCC.aspx")
	   WHILE oOle:ReadyState() != 4  // Aguarda página ser carregada, mesmo q não seja visualizado no Navegador (opão Visible := F ou T)
	      SysWait( .5 )
	   ENDDO
	   try
      oOle := oOle:Document()
      oOle:getElementById("ctl00_cphConteudo_cmbUF"):value := "35"  // 35-> SP
      oOle:getElementById("ctl00_cphConteudo_cmbUF"):Focus()
      oOle:getElementById("ctl00_cphConteudo_cmbUF"):Click()
            
      oOle:getElementById("tbxCNPJContrib"):value := QUAL_CNPJ
	    catch
	    end
	Return( cRet )
	//------------------------------------------------------------------------------
FUNCTION Cria_OLE(cObj_OLE, cMsg, lGetActiveObj)
	   /* Cria objeto Ole */
   LOCAL oObj_OLE := NIL
	   cMsg:='Erro ao Tentar Carregar Pagina...Tente Novamente'
	   lGetActiveObj:=.F.
	   IF lGetActiveObj
	      TRY
	         oObj_OLE := GetActiveObject( cObj_OLE )
	      CATCH
	         TRY
	            oObj_OLE := CREATEOBJECT(cObj_OLE)
	         CATCH
	            Alert(cMsg)
	            RETURN oObj_OLE
	         END
	      END
	   ELSE
	      TRY
	         oObj_OLE := CREATEOBJECT(cObj_OLE)
	      CATCH
	         Alert( cMsg )
	         RETURN oObj_OLE
	      END
	   ENDIF
	RETURN oObj_OLE
	// FIM


 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...