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?
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

CraigM

Active Member
Joined
Feb 27, 2003
Messages
320
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
 

Tobbes

New Member
Joined
Feb 26, 2009
Messages
47
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,126,940
Messages
5,621,732
Members
415,853
Latest member
Newlife72

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
Top