Windows Scripting

  • Thread starter Thread starter Anant Basant
  • Start date Start date
A

Anant Basant

Hi,

I was doing a project in Excel VBA where I needed to capture the list of
installed printers on user's machine and based on that I wanted to limit
access to certain printers. I have heard that Windows Scripting can help
tremendously in such tasks. Does anyone know about a site on the web where I
can explore more about this feature?

Thanks & best regards
Anant
 
Anant,
What do you by "limit access to certain printers" ?
Presumably the user has permission to all the printers installed on the
system. Do you mean that certain files should only be printed on certain
printer(s) ?

NickHK
 
You can find about Windows Scripting at Microsoft Script Center:

http://www.microsoft.com/technet/scriptcenter/default.mspx

Most of the samples are VBScript, but I think you can easily convert them to
VBA. Here is a sample script that lists all the printers on local computer:

Sub ListPrinters()

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")

For Each objPrinter In colInstalledPrinters
Debug.Print "Name: " & objPrinter.Name
Debug.Print "Location: " & objPrinter.Location
Debug.Print "Default: " & objPrinter.Default
Next

End Sub

Hope this is of some help.
 
Hi Nick,

I wanted to have the list of installed printers in a combobox, from where
users can choose the printer they want, and also I could limit the list such
that certain printers (color printers) do not appear in the list. If I use
the option of default print dialog box in my macro, it would list all the
printers available to the user, that is why I didn't want to use this
option.

Further I have found a script centre at
www.microsoft.com/technet/scriptcenter/default.mspx where I can learn more
about scripting.

Thanks very much for your note.

Regards
Anant
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top