Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
Por Eustaquio
#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

----------------------------------------
Avatar do usuário
Por alexandrevba
Avatar
#3839
Boa noite!!

Consegue através desse modelo, adptar o seu?
Código: Selecionar todos
Private Sub UserForm_Activate()
On Error Resume Next
Label1.Caption = Application.ActivePrinter
On Error GoTo 0
If Label1.Caption = "" Then MsgBox "Não há impressora instalada!"
End Sub

Private Sub CommandButton1_Click()
Me.Hide
Application.Dialogs(xlDialogPrinterSetup).Show
Label1.Caption = Application.ActivePrinter
Me.Show
End Sub 
https://support.microsoft.com/en-us/kb/202480

Status da impressora
Código: Selecionar todos
Public Enum Printer_Status 
    PRINTER_STATUS_READY = &H0 
    PRINTER_STATUS_PAUSED = &H1 
    PRINTER_STATUS_ERROR = &H2 
    PRINTER_STATUS_PENDING_DELETION = &H4 
    PRINTER_STATUS_PAPER_JAM = &H8 
    PRINTER_STATUS_PAPER_OUT = &H10 
    PRINTER_STATUS_MANUAL_FEED = &H20 
    PRINTER_STATUS_PAPER_PROBLEM = &H40 
    PRINTER_STATUS_OFFLINE = &H80 
    PRINTER_STATUS_IO_ACTIVE = &H100 
    PRINTER_STATUS_BUSY = &H200 
    PRINTER_STATUS_PRINTING = &H400 
    PRINTER_STATUS_OUTPUT_BIN_FULL = &H800 
    PRINTER_STATUS_NOT_AVAILABLE = &H1000 
    PRINTER_STATUS_WAITING = &H2000 
    PRINTER_STATUS_PROCESSING = &H4000 
    PRINTER_STATUS_INITIALIZING = &H8000 
    PRINTER_STATUS_WARMING_UP = &H10000 
    PRINTER_STATUS_TONER_LOW = &H20000 
    PRINTER_STATUS_NO_TONER = &H40000 
    PRINTER_STATUS_PAGE_PUNT = &H80000 
    PRINTER_STATUS_USER_INTERVENTION = &H100000 
    PRINTER_STATUS_OUT_OF_MEMORY = &H200000 
    PRINTER_STATUS_DOOR_OPEN = &H400000 
    PRINTER_STATUS_SERVER_UNKNOWN = &H800000 
    PRINTER_STATUS_POWER_SAVE = &H1000000 
End Enum 
Att
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord