View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
urkec urkec is offline
external usenet poster
 
Posts: 131
Default Windows Scripting

You can find about Windows Scripting at Microsoft Script Center:

http://www.microsoft.com/technet/scr...r/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.

--
urkec


"Anant Basant" wrote:

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