Net Send in VBA

KyleG

Well-known Member
Joined
Jun 12, 2004
Messages
623
We want to know if it is possible to code into vba instructions to message a pc on a network.

Eg. On workbook close send a message via the 'net send' command to pc nxrandscn1 "changes have been made to rosterfile"

We have been experimenting with the shell component. We wont to be able to send a different message depending on what the activesheet is.

Is this possible?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Maybe something along the lines of:

Code:
Sub NetSend()
Dim sMsg As String
Dim sUser As String

Select Case ActiveSheet.Name
    Case "Sheet1": sMsg = "Sheet1 is active"
    Case Else:  sMsg = "No Message"
End Select

sUser = "user1"

Shell "C:\WINNT\system32\net.exe" & " send " & sUser & " " & sMsg, vbHide

End Sub
 
Upvote 0
I have a problem...
I'm using this code to send a message over the network
Code:
Sub NOTIFY_Click()
Dim strUserName As String
strUserName = Environ("UserName")
Set objShell = CreateObject("WScript.Shell")
netlocation = InputBox("Message To:", "Net Send Message: Location", strUserName)
If netlocation <> "" Then
Message = InputBox("Message:", "Net Send Message: Message", "I need to use this spreadsheet when you're done, thank you!")
If Message <> "" Then
objShell.Run "net send " & netlocation & " " & Message, 0
End If
End If
End Sub

My problem is, where I am using the "Environ("UserName") as the default name to display in the InputBox, I would like to use the username of the user who currently has the spreadsheet open and locked for editing. Not the Excel username but, the Windows log in username.

Anyone know how to get that username as a string?

Cheers in advance.
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,509
Members
448,967
Latest member
screechyboy79

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top