Attribute VB_Name = "MainModule"
Sub Main()
'##############################################################
'# name: set-clip.bas (Visual Basic code for Windows)
'# modified: 2003-09-20 10:48
'# assumes: command line argument is valid -- file exists
'# output: copies contents of file to Windows clipboard
'# usage: set-clip.exe FILENAME
'##############################################################
Dim cmdLine As String
Dim myString As String
Dim iFileNum As Integer
'read command line
cmdLine = Command()
myString = ""
'--------------------------------------------------
' read from file, adding after each line
'--------------------------------------------------
iFileNum = FreeFile
Open cmdLine For Input As #iFileNum
'If (Err.Number = 0) Then
Do While (Not EOF(iFileNum))
Line Input #iFileNum, S
myString = myString & S & vbCrLf
Loop
'End If
Close #iFileNum
'clear clipboard
Clipboard.Clear
'set clipboard
Clipboard.SetText myString
End Sub
|