Getting host name with excel code.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
I dont know why this code is not working.
Please advise. Thanks
Ped;)

Code:
Sub host_name()
Dim ClientMachineEntry As System.Net.IPHostEntry
ClientMachineEntry = System.Net.Dns.GetHostByAddress(Request.ServerVariables.Item("REMOTE_HOST"))
messagebox.Show (ClientMachineEntry.HostName)
End Sub
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
This code too does not work....
Code:
[FONT=Courier New][SIZE=2][COLOR=#0000ff]sub IP_add()[/COLOR][/SIZE][/FONT]
[FONT=Courier New][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myHost [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] = System.Net.Dns.GetHostName[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myIPs [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] System.Net.IPHostEntry = System.Net.Dns.GetHostByName(myHost)[/FONT]
[FONT=Courier New]MessageBox.Show("The name of the host is = " & myIPs.HostName, "Host Name", MessageBoxButtons.OK, MessageBoxIcon.Information)[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] myIP [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Net.IPAddress [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] myIPs.AddressList[/FONT]
[FONT=Courier New]MessageBox.Show("The IP address of host is = " & myIP.ToString, "Host IP Address", MessageBoxButtons.OK, MessageBoxIcon.Information)[/FONT]
[/SIZE][SIZE=2][COLOR=#0000ff][FONT=Courier New]Next[/FONT]
End sub[/COLOR][/SIZE]
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,687
Office Version
2013
Platform
Windows
This looks like .Net code to me ... VBA and VB.Net are not quite the same thing. You could probably run this in Visual Studio Express - to get it into VBA you'd probably need to compile it down to a dll/xll and then reference the code from your VBA project.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,132
Messages
5,509,341
Members
408,727
Latest member
Cantello

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top