Solved

Displaying IP Address using VBA

Posted on 2004-09-18
3
978 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now