I'm a little new to VB and am mostly self-taught, as such my code is probably very inefficient and not done properly: Anyway, to my question, can someone tell me why the following code tells me that the "Name" line gives an Invalid procedure call or argument (Error 5). If I write a test code which does essentially the same thing (without all the search and automation) it works fine... why does the same command in two contexts not work the same?

Code that won't work:
VB Code:
  1. Sub PicRename()
  2.  
  3.     Dim day As String
  4.     day = InputBox("Please enter the folder name as it appears in my pics")
  5.     Dim hour As Integer
  6.     hour = InputBox("Please enter the latest hour (after midnight - on a 24h clock) for pictures to be converted")
  7.     Dim num As Integer
  8.     num = 0
  9.     Dim newnum As Integer
  10.     Dim changer As String
  11.     Dim newnam As String
  12.  
  13. alpha:
  14.     newnum = num + 24
  15.     With Application.FileSearch
  16.         .FileName = "0" & num & "????AA.JPG"
  17.         .LookIn = "C:\Documents and Settings\PCPC\My Documents\My Pictures\" & day & "\"
  18.         .Execute
  19.         If .FoundFiles.Count = 0 Then GoTo Omega
  20.         For i = 1 To 1
  21.             changer = .FoundFiles(i)
  22.             With Selection
  23.                 .TypeText (changer)
  24.                 .MoveLeft unit:=wdCharacter, Count:=10, Extend:=wdMove
  25.                 .MoveLeft unit:=wdCharacter, Count:=2, Extend:=wdExtend
  26.                 .TypeText (newnum)
  27.                 .HomeKey unit:=wdStory, Extend:=wdMove
  28.                 .EndKey unit:=wdStory, Extend:=wdExtend
  29.                 newnam = .Text
  30.                 .Delete
  31.             End With
  32.         Next i
  33.     End With
  34. 'line that doesn't work:    
  35. Name changer As newnam
  36.  
  37. GoTo alpha:
  38. Omega:
  39.     If num < hour Then
  40.         num = num + 1
  41.         GoTo alpha:
  42.     End If
  43.    
  44. End Sub

Code that does work:
VB Code:
  1. Sub Test()
  2.  
  3. Dim changer As String
  4. Dim newnam As String
  5. changer = "C:\Documents and Settings\PCPC\My Documents\My Pictures\2005_1224\005206AA.JPG"
  6. newnam = "C:\Documents and Settings\PCPC\My Documents\My Pictures\2005_1224\245206AA.JPG"
  7.  
  8. Name changer As newnam
  9.  
  10. End Sub

If anyone could help me figure this out it would be greatly appreciated.