elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: AIO elhacker.NET 2021 Compilación herramientas análisis y desinfección malware


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  macros en word...
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: macros en word...  (Leído 2,041 veces)
MITNICK

Desconectado Desconectado

Mensajes: 129



Ver Perfil
macros en word...
« en: 27 Junio 2006, 03:14 am »

Saludo estoy inventando algo con un macros en word que me diga las impresoras que esten ready o si tienen tinta baja o cualquiera opcion que tenga una funcion para esto. Si me podrian ayudar se lo agradeceria.


En línea

Red Mx
Rojito
Colaborador
***
Desconectado Desconectado

Mensajes: 3.649


Viva México Cabrones...


Ver Perfil WWW
Re: macros en word...
« Respuesta #1 en: 27 Junio 2006, 03:57 am »

que codigo tienes para yudarte o que quieres que haga tu trabajo.


En línea

Desarrollar Malware Es Causa De Cancer...
MITNICK

Desconectado Desconectado

Mensajes: 129



Ver Perfil
Re: macros en word...
« Respuesta #2 en: 28 Junio 2006, 05:23 am »

encontre un codigo,  pero no me funciona. Las funciones que quiero que tenga es que me diga son: el status de la impresora y  nivel de tinta esas son basicamente la funciones que quiero que tenga.

El codigo es el siguiente

How can I get a list of the available printer names?

Article contributed by Astrid Zeelenberg

It requires some Windows API trickery, because VBA (unlike VB) does not have a Printers collection. Paste the following into a separate module. The function ListPrinters returns a variant containing an array of printer names.

Option Explicit

Const PRINTER_ENUM_CONNECTIONS = &H4
Const PRINTER_ENUM_LOCAL = &H2

Private Declare Function EnumPrinters Lib "winspool.drv" Alias "EnumPrintersA" _
        (ByVal flags As Long, ByVal name As String, ByVal Level As Long, _
        pPrinterEnum As Long, ByVal cdBuf As Long, pcbNeeded As Long, _
        pcReturned As Long) As Long

Private Declare Function PtrToStr Lib "kernel32" Alias "lstrcpyA" _
        (ByVal RetVal As String, ByVal Ptr As Long) As Long

Private Declare Function StrLen Lib "kernel32" Alias "lstrlenA" _
       (ByVal Ptr As Long) As Long


Public Function ListPrinters() As Variant

Dim bSuccess As Boolean
Dim iBufferRequired As Long
Dim iBufferSize As Long
Dim iBuffer() As Long
Dim iEntries As Long
Dim iIndex As Long
Dim strPrinterName As String
Dim iDummy As Long
Dim iDriverBuffer() As Long
Dim strPrinters() As String

iBufferSize = 3072

ReDim iBuffer((iBufferSize \ 4) - 1) As Long

'EnumPrinters will return a value False if the buffer is not big enough
bSuccess = EnumPrinters(PRINTER_ENUM_CONNECTIONS Or _
        PRINTER_ENUM_LOCAL, vbNullString, _
        1, iBuffer(0), iBufferSize, iBufferRequired, iEntries)

If Not bSuccess Then
    If iBufferRequired > iBufferSize Then
        iBufferSize = iBufferRequired
        Debug.Print "iBuffer too small. Trying again with "; _
        iBufferSize & " bytes."
        ReDim iBuffer(iBufferSize \ 4) As Long
    End If
    'Try again with new buffer
    bSuccess = EnumPrinters(PRINTER_ENUM_CONNECTIONS Or _
            PRINTER_ENUM_LOCAL, vbNullString, _
            1, iBuffer(0), iBufferSize, iBufferRequired, iEntries)
End If

If Not bSuccess Then
    'Enumprinters returned False
    MsgBox "Error enumerating printers."
    Exit Function
Else
    'Enumprinters returned True, use found printers to fill the array
    ReDim strPrinters(iEntries - 1)
    For iIndex = 0 To iEntries - 1
        'Get the printername
        strPrinterName = Space$(StrLen(iBuffer(iIndex * 4 + 2)))
        iDummy = PtrToStr(strPrinterName, iBuffer(iIndex * 4 + 2))
        strPrinters(iIndex) = strPrinterName
    Next iIndex
End If

ListPrinters = strPrinters

End Function
   

'You could call the function as follows:


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

Sub Test()

Dim StrPrinters As Variant, x As Long

StrPrinters = ListPrinters

'Fist check whether the array is filled with anything, by calling another function, IsBounded.
If IsBounded(StrPrinters) Then
    For x = LBound(strPrinters) To UBound(strPrinters)
        Debug.Print StrPrinters(x)
    Next x
Else
    Debug.Print "No printers found"
End If

End Sub


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

Public Function IsBounded(vArray As Variant) As Boolean

    'If the variant passed to this function is an array, the function will return True;
    'otherwise it will return False
    On Error Resume Next
    IsBounded = IsNumeric(UBound(vArray))

End Function


El link de la pagina es http://www.word.mvps.org/FAQs/MacrosVBA/AvailablePrinters.htm

Gracias
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
¿Macros .m4 c++ con eclipse?
Programación C/C++
BlaineMonkey 0 1,545 Último mensaje 28 Diciembre 2010, 12:11 pm
por BlaineMonkey
Macros de Word 2007 con BAT
Scripting
demon 0 3,445 Último mensaje 20 Febrero 2011, 09:23 am
por demon
Dridex, un malware que revive los ataques desde las macros de Microsoft Word
Noticias
wolfbcn 0 1,179 Último mensaje 6 Noviembre 2014, 13:36 pm
por wolfbcn
Locky se une a la fiesta del ransomware en macros de Word
Noticias
wolfbcn 0 1,286 Último mensaje 18 Febrero 2016, 23:01 pm
por wolfbcn
ayuda con macros enumeracion en word
Programación General
polloconrabia 0 1,814 Último mensaje 10 Mayo 2016, 23:31 pm
por polloconrabia
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines