View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Need help - Filesaving - need to increment filename

One way

Sub SaveCmde()
Const sFilebase = "C:\Documents and Settings\guicha\bureau\cano\silo"
Dim sFile As String
Dim iNum As Long
Dim fExists As Boolean

Do
sFile = sFilebase & Format(iNum, "000") & ".txt"
fExists = Len(Dir(sFile))
If Not fExists Then
ActiveWorkbook.SaveAs Filename:=sFile, _
FileFormat:=xlTextMSDOS, _
CreateBackup:=False
Range("A21").Select
End If
Loop Until Not fExists

End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Guillaume" wrote in message
...

Greetings, i need to modify this code to be able to increment the file
name each time i save the file.

for example when i save it to silo001.txt
i want the next one to be silo002.txt , etc..

Here is the code right now ;
----
Sub SaveCmde()

ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\guicha\bureau\cano\silo001.txt",
FileFormat:=xlTextMSDOS, CreateBackup:=False
Range("A21").Select

End Sub
----
I know you guys rock and you will help me out,
im more into hardware so thanks for your help !

Guillaume.




*** Sent via Developersdex http://www.developersdex.com ***