Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting WMI query results using VBA

Status
Not open for further replies.

limester

Technical User
Dec 29, 2004
69
CA
Hello All,

Is there a way to insert into Excel some WMI query results using VBA? So that there is a function in a cell that will auto-insert the results?

Cheers.
 


Hi,

What do you mean by a WMI query?

MS Query can return a resultset to a worksheet quite simply, via menu item Data/Get External Data/New Database Query...

You must have a properly configured ODBC driver for you database to make the next selection.

Then it's more or less like the Access QBE graphical interface with a few LESS bells & whistles.


Skip,

[glasses] [red]Be Advised![/red]
A wee deranged psychic may be runnin' around out there!
SMALL MEDUIM @ LARGE[tongue]
 
Hello SkipVought,

Thank you for your reply. Here is a brief description of WMI:
WMI is the Microsoft implementation of Web Based Enterprise Management (WBEM), which is built on the Common Information Model (CIM), a computer industry standard for defining device and application characteristics so that system administrators and management programs can control devices and applications from multiple manufacturers or sources in the same way.

This was taken from
WMI supports approximately 90 SQL query statements and will provide information about many of the devices, software, too many areas to mention For example, a SELECT * FROM Win32_Processor would give me many results on make/model/serial, etc for the processors installed on a piece of hardware. WMI is builtin to Windows OS from Win2000. The most popular method of accessing this data is by using vbscript. Run wbemtest from command-line to access the namespaces that will provide query functionality.

I am not sure that an OBDC driver would work with WMI.

Cheers.
 
If you know how to do it in VBScript I don't see why you can't do it in VBA.
 
Hi PHV,

Thank you for your reply. I use scripting tools (scriptomatic) that creates the vbscript for me based on the namespace I am attempting to query for.

Is it simply as easy as copying this data into VBA editor?

Cheers.
 
You'll have to replace all WScript.Echo with what you want to do with the collected data.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top