Solved

Displaying IP Address using VBA

Posted on 2004-09-18
3
989 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 46

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…
Suggested Courses
Course of the Month6 days, 7 hours left to enroll

634 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