R
RRodrigues
I've a code to automatically save the Fax template with a sequential number,
in a specific path:
Set fs = Application.FileSearch
With fs
.LookIn = Pathe
.FileName = "F2006*.doc"
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
Nfiles = .FoundFiles.Count
LastFile = .FoundFiles(Nfiles)
Lfile = Mid(LastFile, CharPath + 2, 20)
NChar = Len(Lfile)
Lfile = Left(Lfile, (NChar - 4))
Lfile = Mid(Lfile, 2, 7)
If Lfile <> IsNumeric(Lfile) Then GoTo Line4
FicName = Lfile + 1
MsgBox ("FicName ") & FicName
NFic = Right(FicName, 3)
FicName = "F" & FicName & ".doc"
Else
MsgBox "There were no files found."
End If
End With
On Error GoTo Line4
ChangeFileOpenDirectory Pathe
ActiveDocument.SaveAs FileName:=FicName
The files are saved in the path like F2006001.doc, F2006002.doc and so one.
However, the faxes numbers pass the 1000 and Word assumes that the last file
is F2006999 ( I know, I should start to save them as F20060001, and not as
F2006001 ).
Is there a way to sort the files in order to the last file should be the
F20061000, and not the F2006999?
Ricardo Rodrigues
in a specific path:
Set fs = Application.FileSearch
With fs
.LookIn = Pathe
.FileName = "F2006*.doc"
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
Nfiles = .FoundFiles.Count
LastFile = .FoundFiles(Nfiles)
Lfile = Mid(LastFile, CharPath + 2, 20)
NChar = Len(Lfile)
Lfile = Left(Lfile, (NChar - 4))
Lfile = Mid(Lfile, 2, 7)
If Lfile <> IsNumeric(Lfile) Then GoTo Line4
FicName = Lfile + 1
MsgBox ("FicName ") & FicName
NFic = Right(FicName, 3)
FicName = "F" & FicName & ".doc"
Else
MsgBox "There were no files found."
End If
End With
On Error GoTo Line4
ChangeFileOpenDirectory Pathe
ActiveDocument.SaveAs FileName:=FicName
The files are saved in the path like F2006001.doc, F2006002.doc and so one.
However, the faxes numbers pass the 1000 and Word assumes that the last file
is F2006999 ( I know, I should start to save them as F20060001, and not as
F2006001 ).
Is there a way to sort the files in order to the last file should be the
F20061000, and not the F2006999?
Ricardo Rodrigues