Этот баннер — требование Роскомнадзора для исполнения 152 ФЗ.
«На сайте осуществляется обработка файлов cookie, необходимых для работы сайта, а также для анализа использования сайта и улучшения предоставляемых сервисов с использованием метрической программы Яндекс.Метрика. Продолжая использовать сайт, вы даёте согласие с использованием данных технологий».
Политика конфиденциальности
|
|
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
См сабж.... Можно ли по средством кода в VBA установить новый принтер? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.07.2004, 16:07 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
так настроить или добавить ? имхо самое простое это вызвать соотв аплет панели управления есть и api PrintDialog . ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.07.2004, 16:17 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
добавить ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.07.2004, 16:18 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
вот что пишет Апплеман AddPrinter VB Declaration Declare Function AddPrinter& Lib "winspool.drv" Alias "AddPrinterA" (ByVal pName_ As String, ByVal Level As Long, pPrinter As Byte) Description Adds a new printer to the system. Use with VB No problem. Parameter Type/Description pName String—The name of the server on which to install the print processor. Set to vbNullString for a local printer. Level Long—Set to 2. pPrinter Byte—First entry in a buffer containing a PRINTER_INFO_2 structure that has the fields pPrinterName, pPortName, pDriverName, pPrintProcessor and pDataType fields set to valid values. pPrinter can also be defined to be As PRINTER_INFO_2. The fields: Attributes, DefaultPriority, pComment, pDevMode, pLocation, pParameters, Priority, pSecurityDescriptor, pSepFile, pShareName, StartTime and UntilTime may also be set. Other fields should be left empty. Return Value Long—A handle to a new printer on success, zero on failure. Sets GetLastError. Platform Windows 95, Windows NT. Under NT, the caller must have sufficient privilege to configure printers on the specified server. All of the material presented here is copyrighted by either Desaware or Macmillan. No part of this material may be used or reproduced in any fashion (except in brief quotations used in critical articles and reviews) without prior consent. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.07.2004, 16:28 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
если надо, то вот описание структуры PRINTER_INFO_2 VB Declaration Type PRINTER_INFO_2 pServerName As Long pPrinterName As Long pShareName As Long pPortName As Long pDriverName As Long pComment As Long pLocation As Long pDevMode As Long pSepFile As Long pPrintProcessor As Long pDatatype As Long pParameters As Long pSecurityDescriptor As Long ‘SECURITY_DESCRIPTOR Attributes As Long Priority As Long DefaultPriority As Long StartTime As Long UntilTime As Long Status As Long cJobs As Long AveragePPM As Long End Type Description This structure contains detailed information on the printer. Field Type/Description pServerName Long—The address of a string buffer containing the name of the server for the printer. Zero or a null string for local printers. pPrinterName Long—The address of a string buffer containing the name of the printer. pShareName Long—The address of a string buffer containing the share name for the printer (valid only if printer is shared). pPortName Long—The address of a string buffer containing the name of the printer port that it is connected to (multiple port names are separated by commas). pDriverName Long—The address of a string buffer containing the name of the printer driver. pComment Long—See PRINTER_INFO_1. pLocation Long—The address of a string buffer containing the location of the printer. pDevMode Long—The address of a DEVMODE structure that defines default settings for the printer. pSepFile Long—The address of a string buffer containing the name of a file that is used to create separator pages to separate between print jobs. pPrintProcessor Long—The address of a string buffer containing the name of the print processor for the printer. pDatatype Long—The address of a string buffer containing the type of data used when recording the print job. pParameters Long—The address of a string buffer containing default print-processor parameters. pSecurityDescriptor Long—The address of a SECURITY_DESCRIPTOR structure for the printer. This member may be zero. Attributes Long—Specifies printer attributes, can be any of the following: PRINTER_ATTRIBUTE_QUEUED, PRINTER_ATTRIBUTE_DEFAULT, PRINTER_ATTRIBUTE_DIRECT, PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST, PRINTER_ATTRIBUTE_ENABLE_BIDI, (Windows 95 only) PRINTER_ATTRIBUTE_DIRECT, PRINTER_ATTRIBUTE_DEFAULT, PRINTER_ATTRIBUTE_SHARED, PRINTER_ATTRIBUTE_WORK_OFFLINE (Windows 95 only) Priority Long—The priority that the spooler uses to route print jobs. DefaultPriority Long—The default priority for print jobs on this printer. StartTime, UntilTime Long—Specifies the earliest and latest time at which the printer will print a job (specified in minutes from 12:00 a.m.). Status Long—Specifies printer status.In Windows NT, PRINTER_STATUS_PAUSED or PRINTER_STATUS_PENDING_DELETION.Any constant with the prefix PRINTER_STATUS_* under Windows 95. cJobs Long—The number of jobs in the print queue for this printer. AveragePPM Long—The average number of pages per minute for this printer. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.07.2004, 16:30 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
Слушайте, а это прям в VBA делать? Я чет вообще неврубаюсь что к чему и с чем в этих кодах..... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.07.2004, 09:36 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
ну да прямо в vba. вставляешь модуль, объявляешь функции, структуры и константы и вперед в чеб трабл собственно ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.07.2004, 09:53 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
Трабла в том что чайник я, сижу вот с книжкой по VBA 2002 ну и в инете кое что подбираю....... 8))) щас сижу втыкаю что к чему 8) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.07.2004, 09:58 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.07.2004, 10:05 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
спс... Как там в песне было? -Все мне ясно стало теперь..... 8))) Спасибки.... Да кстати может еще подскажете как копировать папку с кучей файлов внуткри, ато в код 50 файлов на копирование загонять неохота 8) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.07.2004, 10:24 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.07.2004, 10:58 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
Блин проблемма - Declare Function addprinter& Lib "winspool.drv" Alias "AddPrinterA" (ByVal pName As String, ByVal Level As Long, pPrinter As Byte) на этой строчке выдает следующую ошибку : Compile Error: Only comments may appear after End Sub, End Function, or End properly че за бадяга? хотя перед етой строчкой только Sub tata(0 и все и никакое упоминание End Sub, End Function, or End properly...... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.07.2004, 12:35 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
Declare пишется в начале модуля, перед объявлением прочих Sub и Function ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.07.2004, 13:59 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
Да, уже врубился, нашел вот такое вот чудо: Public Type PRINTER_INFO_2 pServerName As Long 'String pPrinterName As Long 'String pShareName As Long 'String pPortName As Long 'String pDriverName As Long 'String pComment As Long 'String pLocation As Long 'String pDevMode As Long ' DEVMODE pSepFile As Long 'String pPrintProcessor As Long 'String pDatatype As Long 'String pParameters As Long 'String pSecurityDescriptor As Long 'SECURITY_DESCRIPTOR Attributes As Long Priority As Long DefaultPriority As Long StartTime As Long UntilTime As Long Status As Long cJobs As Long AveragePPM As Long End Type Public Type PRINTER_DEFAULTS pDatatype As Long 'String pDevMode As Long 'DEVMODE DesiredAccess As Long End Type Public Declare Function AddPrinter Lib "winspool.drv" Alias "AddPrinterA" (ByVal pName As String, ByVal Level As Long, pPrinter As PRINTER_INFO_2) As Long Public Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long Public Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long Public Declare Function DeletePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long Public Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As Long, ByVal lpString2 As String) As Long Public Const STANDARD_RIGHTS_REQUIRED = &HF0000 Public Const PRINTER_ACCESS_ADMINISTER = &H4 Public Const PRINTER_ACCESS_USE = &H8 Public Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE) ' ' This code adds a printer to a Windows NT/2000 server/workstation ' ' Written by Tony Edgecombe ' Tony.Edgecombe@frogmorecs.co.uk ' www.vbprint.com ' 22 Jan 2001 ' ' Function CreatePrinter(strServer As String, _ strPrinter As String, _ strPort As String, _ strDriver As String, _ strPrintProcessor As String) As Boolean Dim hPrinter As Long Dim pi2 As PRINTER_INFO_2 Dim bBuffer(1000) As Byte Dim i '********************************************************************* ' Initialise our buffer '********************************************************************* For i = 0 To UBound(bBuffer) bBuffer(i) = 0 Next '********************************************************************* ' Set the pointers to the string values in bBuffer '********************************************************************* pi2.pPrinterName = AddString(strPrinter, bBuffer) pi2.pPortName = AddString(strPort, bBuffer) pi2.pDriverName = AddString(strDriver, bBuffer) pi2.pPrintProcessor = AddString(strPrintProcessor, bBuffer) '********************************************************************* ' Default all other values to 0 (NULL) '********************************************************************* pi2.Attributes = 0 pi2.AveragePPM = 0 pi2.cJobs = 0 pi2.DefaultPriority = 0 pi2.pComment = 0 pi2.pDatatype = 0 pi2.pDevMode = 0 pi2.pLocation = 0 pi2.pParameters = 0 pi2.Priority = 0 pi2.pSecurityDescriptor = 0 pi2.pSepFile = 0 pi2.pServerName = 0 pi2.pShareName = 0 pi2.StartTime = 0 pi2.Status = 0 pi2.UntilTime = 0 '********************************************************************* ' Add the printer ' If success then close the returned handle '********************************************************************* hPrinter = AddPrinter(strServer, 2, pi2) If hPrinter <> 0 Then ClosePrinter (hPrinter) CreatePrinter = True Else CreatePrinter = False End If End Function Private Function AddString(strString As String, ByRef bBuffer() As Byte) As Long '********************************************************************* ' AddString copies a string into a Byte array and returns a long ' pointer to that string '********************************************************************* Dim lngEnd As Long lngEnd = UBound(bBuffer) + 1 Do lngEnd = lngEnd - 1 Loop While (bBuffer(lngEnd) = 0 And lngEnd > 0) lngEnd = lngEnd + 2 lstrcpy VarPtr(bBuffer(0)) + lngEnd, strString AddString = VarPtr(bBuffer(0)) + lngEnd End Function Function RemovePrinter(strPrinter As String) Dim hPrinter As Long Dim pd As PRINTER_DEFAULTS '********************************************************************* ' Create a PRINTER_DEFAULTS structure with the required access rights '********************************************************************* pd.pDatatype = 0 pd.pDevMode = 0 pd.DesiredAccess = PRINTER_ALL_ACCESS '********************************************************************* ' Open the printer '********************************************************************* If OpenPrinter(strPrinter, hPrinter, pd) = 0 Then RemovePrinter = False Exit Function End If '********************************************************************* ' Remove it '********************************************************************* If DeletePrinter(hPrinter) = 0 Then RemovePrinter = False Exit Function End If '********************************************************************* ' Release the handle '********************************************************************* ClosePrinter (hPrinter) RemovePrinter = True End Function Sub main() '********************************************************************* ' Test call ' ' The parameters to CreatePrinter are: ' ' Server Name - Blank if local machine ' Printer Name - Must be unique ' Port Name - Port must be installed already ' Driver Name - Driver must be installed already ' Print Processor - Must be installed already ' '********************************************************************* MsgBox "Printer Creation: " & CreatePrinter("", "New Printer", "LPT1:", "HP LaserJet 1100 (MS)", "WinPrint") '********************************************************************* ' Test Call ' Parameter is the name of the printer to delete ' ' For printers on another server use the UNC path ie \\Server\Printer '********************************************************************* MsgBox "Printer Deletion: " & RemovePrinter("New Printer") End Sub Написано под НТ, я делаю под XP... из за малеького багажа знания в VBA не врубаюсь что править нада... при запуске проги вылетает два месаджбока адд - фальс делит - фальс... ничего не создается... подскажите что где править.... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.07.2004, 14:13 |
|
||
|
Можно ли через VBA настроить принтер?
|
|||
|---|---|---|---|
|
#18+
Мда - тормоз ето судьба 8))))))) MsgBox "Printer Creation: " & CreatePrinter("", "Имя принтера", "Порт", "Название принтера", "WinPrint") Ето убираем или лочим MsgBox "Printer Deletion: " & RemovePrinter("New Printer") Как круто! Все пашет!... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.07.2004, 17:18 |
|
||
|
|

start [/forum/topic.php?fid=60&gotonew=1&tid=2169164]: |
0ms |
get settings: |
8ms |
get forum list: |
11ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
80ms |
get topic data: |
9ms |
get first new msg: |
7ms |
get forum data: |
2ms |
get page messages: |
50ms |
get tp. blocked users: |
1ms |
| others: | 245ms |
| total: | 421ms |

| 0 / 0 |
