borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (How to output data on the printer port?)Next Topic (two columns in Combo Box ) New Topic New Poll Post Reply
AndreaVB Forum : VB General : saving files
Poster Message
apurk45
Level: Guest


icon saving files  Archived to Disk

Hello
I have a excel template file "pic.xlt" and every time I input a new data into it I need to save it as sequential .xls file ie pic1.xls then pic2.xls and next time pic3.xls etc. I would like put this code into my macro so user would not have to name file durring saving.
Please advise how can I do it
Thanks
John

13-07-2002 at 06:44 AM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: saving files  Archived to Disk

Following could be helpful

' ----START MACRO ----

Private Sub SaveMacro()
    Dim i As Integer
    Dim str As String
    
    Do
        i = i + 1
    ' str = <path>Pic1.xls to <path>Pic10000.xls
    ' ThisWorkbook.Path is the current path of the workbook
        str = ThisWorkbook.Path & "Pic" & CStr(i) & ".xls"
    ' Bbefore file is saved there is NO path set default here
        If Left(str, 1) = "" Then str = "G:" & str
        If Dir(str) = "" Then
            ThisWorkbook.SaveAs str
            str = "<FS>"
        End If
    Loop Until i >= 32000 Or str = "<FS>"
End Sub

' ---- END MACRO ----

13-07-2002 at 05:32 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : VB General : saving files
Previous Topic (How to output data on the printer port?)Next Topic (two columns in Combo Box ) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder