Solved

Displaying IP Address using VBA

Posted on 2004-09-18
3
981 Views
Last Modified: 2013-12-25
Hi

I am using the following code to try and display the IP Address

Public Function IndIPAddress()

Set IPConfigSet = GetObject("winmgmts:").ExecQuery("select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IPConfig In IPConfigSet
    If Not IsNull(IPConfig.IPAddress) Then
        For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
            MsgBox "IPAddress: " & IPConfig.IPAddress(i)
        Next
    End If
Next

End Function

It errors out at (IPConfifSet)

Set IPConfigSet = GetObject("winmgmts:").ExecQuery.........................

Error Message

Variable not defined

What am I missing?

Many thanks

0
Comment
Question by:martmac
  • 2
3 Comments
 
LVL 45

Assisted Solution

by:aikimark
aikimark earned 250 total points
ID: 12093944
if you have Option Explicit in your General Declarations section, you will need to define a "IPConfigSet" variable.
0
 
LVL 13

Accepted Solution

by:
Michael_D earned 250 total points
ID: 12103940
Put

Dim IPConfigSet as Object

at the begining of your function
0
 
LVL 13

Expert Comment

by:Michael_D
ID: 12103968
and
Dim IPConfig as Object

as well
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to skip loop 6 62
MsgBox 2 59
VB6 - Convert HH:MM into Decimal 8 62
Problem to With line 4 63
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question