Solved

Displaying IP Address using VBA

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

803 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