+ Reply to Thread
Results 1 to 3 of 3

Get IP Address of Current computer.

  1. #1
    Registered User
    Join Date
    08-22-2014
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    81

    Get IP Address of Current computer.

    I everyone.

    Im trying to: 1) Find out the IP address of the computer my workbook is currently open on.
    2) Store that value on a sheet (called "Settings") once the workbook is open.
    note: the workbook would need to save as soon as it has opened, storing this value.
    3) When opening the same workbook from another computer get a msgbox with the IP address of the computer that has it open, by reading the value that is stored on the "Settings" sheet.

    i need some help working out just how to get this to work correctly.

    Here is what i have done so far.

    My workbook opens and if it is not Readonly then the following code will run to find the IP address.

    Please Login or Register  to view this content.
    this works fine at home, But it does not work in my work place. maybe the fact that each computer is administrator locked out that it causes the code to fail. in fact it seems to behave in a very different manner at work.

    for example the line:
    Please Login or Register  to view this content.
    fails firstly because the .txt file i'm attempting to store the IP address in has no text at all in it. Yet at home it works fine even if no text is in the .txt file. Also the
    Please Login or Register  to view this content.
    actually deletes the file altogether from the computer at work yet does not at home.

    if this code worked, or i knew why at my workplace it does not then that would be great.

    So i thought about doing this differently you see in order to open this workbook, you are opening a VBS script that opens the excel file like this:

    Please Login or Register  to view this content.
    I do this so that you can't see the Excel worksheets and all you see is the userforms that make this program work.

    so i thought why not find a VBS that can get an IP address, and works in the workplace. And i did i found this:

    Please Login or Register  to view this content.
    This works perfectly, so i thought why not integrate this with the VBS that opens the workbook, store the value in the workbook instead of showing you in a msgbox.

    but getting it to integrate correctly has been bit of a problem.

    i've tried this as the VBS that opens the program:

    Please Login or Register  to view this content.
    and then once the workbook is open it is set to save itself. so that the value is stored in the workbook, and if you attempt to open this same workbook elsewhere on the network it should read the value on the sheet as in the workbook open command i have a msgbox that tells you where the workbook is open.

    what actually happens is that i can open the original workbook, it gets the IP address fine from the VBS code (note im not useing the first lot of code i posted just the VBS code), it stores it on the sheet where i want it. the workbook saves.

    i attempt to run the VBS again while the original is still open thus making the this attempt to open the file ReadOnly. the workbook_open sub runs it displays a msgbox that should! have my now stored IP address of where the original file is open and editable. BUT IT DOESN'T, it still displays the value that was there before the original file was opened.

    even tho my original workbook is saved while it was editable, for the life of me why isn't the value that would be stored on the sheet not appearing when i open another instance of this workbook even tho it would only be read only mode, the value should be on the sheet there to read.

    I know this has been rather long winded but i just wanted to ensure you knew i had tried several different things.

    Regards

    Andrew

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often 365, but still time to time use also older versions
    Posts
    8,038

    Re: Get IP Address of Current computer.

    Hi, give a try to the code by Wayne Phillips (insert it in standard module) It does not need to access any local file resources so shall be "adminproof" :-P

    Please Login or Register  to view this content.
    testing:

    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    08-22-2014
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    81

    Re: Get IP Address of Current computer.

    Thank you for your speedy reply Kaper

    It works at home but it will be another 12 hours before i am at work to test it there. fingers crossed it all works

    Many thanks

    Andrew.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 02-20-2013, 12:10 PM
  2. VBA Read the MAC address of a computer ? (Mac OSX Excel 2011)
    By PoeticKinetics in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2012, 10:26 PM
  3. Get current cell address
    By The_Vulcan in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-20-2006, 10:39 PM
  4. Get IP address for a remote computer based on its hostname
    By stabilo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2006, 03:15 PM
  5. Excel /vba / computer IP address
    By jolipe in forum Excel General
    Replies: 1
    Last Post: 06-03-2005, 06:05 PM
  6. Excel /vba / computer IP address
    By jolipe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-03-2005, 03:05 PM
  7. Excel /vba / computer IP address
    By jolipe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2005, 02:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1