- 30 Set 2015 às 21:38
#3838
Estou com esse script
A função dele é captar informações do status de toner da impressoras via rede.
porem quando uma impressora esta desligada, o mesmo para de executar.
Preciso de criar uma exceção, para corrigir esse erro. Voce pode me ajudar?
Segue o link da minha planilha:http://1drv.ms/1KEBI7k
---------------------------------------
Option Explicit
Public Sub spuRetornarStatusToner()
Dim wbk As Excel.Workbook
Set wbk = Excel.ThisWorkbook
Dim wsh As Excel.Worksheet
Set wsh = wbk.Sheets("CONTROLE")
Dim nvgInternetExplorer As InternetExplorer
Dim objIeDoc As Object
Dim htmLinha As HTMLTableRow
Dim htmColuna As HTMLTableCol
Dim i As Integer
For i = 1 To 28
Set nvgInternetExplorer = CreateObject("InternetExplorer.Application")
nvgInternetExplorer.Navigate wsh.Range("D" & 3 + i).Value
'nvgInternetExplorer.Visible = True
While nvgInternetExplorer.ReadyState <> 4
Wend
Set objIeDoc = nvgInternetExplorer.Document.frames.Item(2).Document
For Each htmLinha In objIeDoc.all.tags("tr")
For Each htmColuna In htmLinha.all.tags("td")
If Left$(htmColuna.innerText, 16) = "Cartucho Preto ~" Then
wsh.Range("F" & 3 + i).Value = Right$(htmColuna.innerText, Len(htmColuna.innerText) - 16)
End If
Next htmColuna
Next htmLinha
nvgInternetExplorer.Quit
Next i
Set nvgInternetExplorer = Nothing
Set objIeDoc = Nothing
Close
End Sub
----------------------------------------
A função dele é captar informações do status de toner da impressoras via rede.
porem quando uma impressora esta desligada, o mesmo para de executar.
Preciso de criar uma exceção, para corrigir esse erro. Voce pode me ajudar?
Segue o link da minha planilha:http://1drv.ms/1KEBI7k
---------------------------------------
Option Explicit
Public Sub spuRetornarStatusToner()
Dim wbk As Excel.Workbook
Set wbk = Excel.ThisWorkbook
Dim wsh As Excel.Worksheet
Set wsh = wbk.Sheets("CONTROLE")
Dim nvgInternetExplorer As InternetExplorer
Dim objIeDoc As Object
Dim htmLinha As HTMLTableRow
Dim htmColuna As HTMLTableCol
Dim i As Integer
For i = 1 To 28
Set nvgInternetExplorer = CreateObject("InternetExplorer.Application")
nvgInternetExplorer.Navigate wsh.Range("D" & 3 + i).Value
'nvgInternetExplorer.Visible = True
While nvgInternetExplorer.ReadyState <> 4
Wend
Set objIeDoc = nvgInternetExplorer.Document.frames.Item(2).Document
For Each htmLinha In objIeDoc.all.tags("tr")
For Each htmColuna In htmLinha.all.tags("td")
If Left$(htmColuna.innerText, 16) = "Cartucho Preto ~" Then
wsh.Range("F" & 3 + i).Value = Right$(htmColuna.innerText, Len(htmColuna.innerText) - 16)
End If
Next htmColuna
Next htmLinha
nvgInternetExplorer.Quit
Next i
Set nvgInternetExplorer = Nothing
Set objIeDoc = Nothing
Close
End Sub
----------------------------------------