As you said your co-worker is an experienced programmer, this VB-Scipt might be a good start.
Save the code below my name in a textfile and name the file test.vbs
Create 2 test files test.xls and test.doc in a directory, i.E: C:\temp
Open the command line prompt and execute "wscript test.vbs C:\temp\test.doc Version6.0" (without the "")
Andreas.
'Get the arguments from the command line
Set Args = WScript.Arguments
If Args.Count < 2 Then
MsgBox "test.vbs FileName VersionMsg"
WScript.Quit
Else
Filename = Args(0)
VersionMsg = Args(1)
End If
'Check if the file exists
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(Filename) Then
MsgBox "File not found:" & vbCrLf & Filename
WScript.Quit
End If
'The extension let us know which filetype we should open
Select Case LCase(fso.GetExtensionName(Filename))
Case "xls"
'Get or open Excel
On Error Resume Next
Set objExcel = GetObject(, "Excel.Application")
CloseApp = False
If objExcel Is Nothing Then
Set objExcel = CreateObject("Excel.Application")
CloseApp = True
End If
If objExcel Is Nothing Then
MsgBox "Excel is not accessible"
WScript.Quit
End If
'Try open the file
Set objBook = objExcel.Workbooks.Open(Filename)
If objBook Is Nothing Then
MsgBox "Can not open " & Filename
WScript.Quit
End If
'Remove an existing one if any
Set objShape = objBook.ActiveSheet.Shapes("VersionMsg")
If Not objShape Is Nothing Then objShape.Delete
'Add a textbox to the left upper edge
Set objShape = objBook.ActiveSheet.Shapes.AddTextbox(1, 1, 1, 100, 50)
objShape.Name = "VersionMsg"
'Place the text into
objShape.TextFrame.Characters.Text = VersionMsg
'Save and close the file
objBook.Close True
'Close the application if wasn't open
If CloseApp Then objExcel.Quit
Case "doc"
On Error Resume Next
Set objWord = GetObject(, "Word.Application")
CloseApp = False
If objWord Is Nothing Then
Set objWord = CreateObject("Word.Application")
CloseApp = True
End If
If objWord Is Nothing Then
MsgBox "Word is not accessible"
WScript.Quit
End If
Set objDoc = objWord.Documents.Open(Filename)
If objDoc Is Nothing Then
MsgBox "Can not open " & Filename
WScript.Quit
End If
Set objShape = objDoc.Shapes("VersionMsg")
If Not objShape Is Nothing Then objShape.Delete
Set objShape = objDoc.Shapes.AddTextbox(1, 1, 1, 100, 50)
objShape.Name = "VersionMsg"
objShape.TextFrame.TextRange.Text = VersionMsg
objDoc.Close True
If CloseApp Then objWord.Quit
Case Else
MsgBox "Unknown extension"
End Select