Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Displaying IP Address using VBA

Posted on 2004-09-18
3
Medium Priority
?
992 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 46

Assisted Solution

by:aikimark
aikimark earned 750 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 750 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

972 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