If Len(A$) > 4 Then
A$ = Format(CLng(IIf(Right(A$, 4) = ".pdf", Trim(Left(Range("a" & i& & "").Value, Len(Range("a" & i& & "").Value) - 4)), Trim(Range("a" & i& & "").Value))), "0000000") & ".pdf"
Else
A$ = Format(CLng(A$), "0000000") & ".pdf"
End If