I believe you are looking for something like this.
Code:
Dim str_Data As String
Open "C:\TestFile.Txt" For Input As #1
Do While Not EOF(1)
Input #1, str_Data
With mNetSend
.Message = "Shutting down in 5 mins"
.SendTo = Trim(str_Data)
.NetSendMessage
End With
Doevents
Loop
Close #1
I think I know what you are doing. Are you trying to send messages across the network using Net Send?
If that is the case, there is an easier way to this. Your method only sends the message to one person at a time. If you are interest, I can show you how to send it as a batch file, so that everyone pretty much gets the message at the same time. I did it with about 20 lines of code in Excel VBA.
Good Night...
Sorry, I forgot all about you. I am back now.
You might have to tweak the code around to customize to your network. This is the basic idea. Just paste it into an Excel module and do a step through.
Code:
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Const INFINITE = -1&
Private Const SYNCHRONIZE = &H100000
Sub Macro1()
' Application.Run Macro:="ATTMACRO"
Application.DisplayAlerts = False
Dim lngShell As Long
Dim ret As Long
Dim pHandle As Long
lngShell = Shell(Environ("COMSPEC") & " /C Net View > " & """" & "C:\People.txt" & """", vbNormalFocus)
pHandle = OpenProcess(SYNCHRONIZE, False, lngShell)
ret = WaitForSingleObject(pHandle, INFINITE)
ret = CloseHandle(pHandle)
'PURPOSE:Open the file People.txt and manipulate the data
Workbooks.OpenText FileName:="C:\People.txt", Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth
Rows("1:4").Delete
Columns("B:B").Delete Shift:=xlToLeft
Do Until Left(ActiveCell.Value, 2) <> "\\"
ActiveCell.Offset(0, 1).Value = "Net Send " & Mid(ActiveCell.Value, 3) & " """ & "Howdy!" & """"
ActiveCell.Offset(1, 0).Select
Loop
Columns("A:A").Delete Shift:=xlToLeft
'PURPOSE:Write the data from People.txt out to Send.bat
Range("A1").Select
Open "C:\Send.Bat" For Output As #1
Do Until ActiveCell.Value = ""
Print #1, ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Loop
Close #1
Call Shell("C:\Send.Bat", vbHide)
Application.Quit
End Sub