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
  • Avatar do usuário
#2660
Boa tarde,

Estou querendo criar um script VBA, para executar a tarefa de captar o status do toner das impressoras graficamente ou em porcentagem. No parque são 20 impressoras.

Lembrando que as impressoras estão em rede.

Modelos das impressoras:

MX611DHE - IMPRESSORA LEXMARK MONO

C748DE - IMPRESSORA LEXMARK COLOR

Isso é possível?
#2663
Eustáquio,

A questão é onde está a informação da quantidade de tinta das impressoras. Somente se você possuir um driver que informe em um arquivo ou algo parecido (registro do windows). Não sei onde ficam guardadas as informações da quantidade de tinta. Acredito que na memória do próprio cartucho de tinta. Neste caso, acho pouco provável que você consiga fazer o que está pretendendo.
#2688
Bom dia!!

Tem uma função que verifica algo assim, mas você terá que adaptar.
Código: Selecionar todos
Option Explicit

Private Enum PrinterStatusConstants
    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
#If False Then
Dim PRINTER_STATUS_PAUSED, PRINTER_STATUS_ERROR, PRINTER_STATUS_PENDING_DELETION, _
PRINTER_STATUS_PAPER_JAM, PRINTER_STATUS_PAPER_OUT, PRINTER_STATUS_MANUAL_FEED, _
PRINTER_STATUS_PAPER_PROBLEM, PRINTER_STATUS_OFFLINE, PRINTER_STATUS_IO_ACTIVE, _
PRINTER_STATUS_BUSY, PRINTER_STATUS_PRINTING, PRINTER_STATUS_OUTPUT_BIN_FULL, _
PRINTER_STATUS_NOT_AVAILABLE, PRINTER_STATUS_WAITING, PRINTER_STATUS_PROCESSING, _
PRINTER_STATUS_INITIALIZING, PRINTER_STATUS_WARMING_UP, PRINTER_STATUS_TONER_LOW, _
PRINTER_STATUS_NO_TONER, PRINTER_STATUS_PAGE_PUNT, PRINTER_STATUS_USER_INTERVENTION, _
PRINTER_STATUS_OUT_OF_MEMORY, PRINTER_STATUS_DOOR_OPEN, PRINTER_STATUS_SERVER_UNKNOWN, _
PRINTER_STATUS_POWER_SAVE
#End If

Private Type PRINTER_INFO_6
    dwStatus As PrinterStatusConstants
End Type

Private Declare Function ClosePrinter Lib "spoolss.dll" (ByVal hPrinter As Long) As Long
Private Declare Function GetPrinterW Lib "winspool.drv" (ByVal hPrinter As Long, ByVal Level As Long, ByRef pPrinter As Any, ByVal cbBuf As Long, ByRef pcbNeeded As Long) As Long
Private Declare Function OpenPrinterW Lib "winspool.drv" (ByVal pPrinterName As Long, ByRef phPrinter As Long, Optional ByVal pDefault As Long) As Long

Public Function IsPrinterReady(ByRef PrinterName As String) As Boolean
    Dim hPrinter As Long, pcbNeeded As Long, PI6 As PRINTER_INFO_6

    If OpenPrinterW(StrPtr(PrinterName), hPrinter) Then
        If GetPrinterW(hPrinter, 6&, PI6, LenB(PI6), pcbNeeded) Then
            Debug.Assert pcbNeeded = LenB(PI6)
            IsPrinterReady = PI6.dwStatus = 0&
        End If
        hPrinter = ClosePrinter(hPrinter):  Debug.Assert hPrinter
    End If
End Function
#3040
Alexandre,

Gostaria apenas o status de toner em porcentagem, inclusive não estou conseguindo implementar em minha planilha o Código acima.

O codigo abaixo seria para direcionar o dados para as (Linha,coluna).
----------------------------------------------------------------------------------------------------------------------------

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 i As Integer

For i = 1 To 20
wsh.Range("F" & 3 + i).Value = "insira aqui o status de toner obtido pelo navegador"
Next i

End Sub

-------------------------------------------------------------------------------------------------------------------

Lembrando que as impressoras estão em rede. E consigo acessar o status no navegador de internet.

Nesse caso eu posso gravar uma macro fazendo a importação de uma página de internet e problema resolvido, além de atualizar o status periodicamente?
Estou com uma possível solução mas não consegui implementar em minha planilha, você pode me dar um apoio?

Segue em anexo a solução e a planilha a ser implementada.

Para eu analisar o nivel de toner das 20 impressoras que sou responsável, será preciso criar um user form e um botão?

Ou qual recurso exatamente eu poderia usar.

Conforme a planilha em anexo os dados serão exibidos pelo Range F4 a F24.

E no arquivo script_commands, encontra-se a linha de comando HTML da impressora.

Segue o link ( http://1drv.ms/1Ns5HS1 ) da minha planilha que estou implementando e codigo html da impressora.




Obrigado
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