I am looking for assistance in using variables provided by a text file with the objWS.Range(start, end).BorderAround function. My issue is that I receive a "Type Mismatch" error with the current method I use. I am using VB 6 Enterprise edition and MS Excel 2000.

The purpose of my program is to create templates in a text file that VB will call to create a spreadsheet. This allows me to create new templates (text files) without hard coding them into my VB application.

The text file contains many lines but the one I am concerned with is:
ran,border,A4,G4,xlContinuous,xlThick,xlColorIndexAutomatic

The actual command that works if hard coded in VB is:
vbcode Code:
  1. objWS.Range("A4", "G4").BorderAround xlContinuous, xlThick, xlColorIndexAutomatic

The code I am using that does NOT work is:
vbcode Code:
  1. Public Function xlFeed(strInputFile As String, strOutputFile As String)
  2. Dim i As Integer
  3. Dim sngTemp As Single
  4. Dim strLine As String
  5. Dim strWord() As String
  6. Dim objXL As Object
  7. Dim objWB As Excel.Workbook
  8. Dim objWS As Excel.Worksheet
  9. Dim objRange As Excel.Range
  10.  
  11. Set objXL = CreateObject("Excel.Application")
  12. objXL.Visible = True
  13. Set objWB = objXL.Workbooks.Add()
  14. Set objWS = objWB.Worksheets(1)
  15. Open strInputFile For Input As #71
  16. Do Until EOF(71)
  17.     Line Input #71, strLine
  18.     strLine = Pack(strLine)
  19.     strLine = Trim(strLine)
  20.     strWord = Split(strLine, ",")
  21.     If UBound(strWord) >= 6 Then
  22.         If LCase(strWord(0)) = "ran" Then
  23.             If LCase(strWord(1)) = "border" Then
  24.                 objWS.Range(strWord(2), strWord(3)).BorderAround strWord(4), strWord(5), strWord(6)
  25.             End If
  26.         End If
  27.     End If
  28. Loop
  29. objWB.ActiveSheet.SaveAs (strOutputFile)
  30. objWB.Close
  31. objXL.Quit
  32. Set objRange = Nothing
  33. Set objWS = Nothing
  34. Set objWB = Nothing
  35. End Function

strInputFile is the text file; strOutputFile is a new Excel spreadsheet. When I comment out the tail of the command in question the error disappears but I do not get the border I want:

vbcode Code:
  1. objWS.Range(strWord(2), strWord(3)).BorderAround 'strWord(4), strWord(5), strWord(6)

Any help would be greatly appreciated. Thank You,