Consulting

Results 1 to 4 of 4

Thread: Solved: SaveAs Macro Code

  1. #1
    VBAX Mentor jammer6_9's Avatar
    Joined
    Apr 2007
    Location
    Saudi Arabia
    Posts
    318
    Location

    Solved: SaveAs Macro Code

    How can I write a code that will save as the workbook with newworkbook and in a certain location

    [vba]Sub SaveAs()
    ActiveWorkbook.SaveAs ("New")
    End Sub

    [/vba]
    T-ogether
    E-veryone
    A-chieves
    M-ore


    One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Here's a start...I used the macro recorder to get this:
    [VBA]Sub Macro1()
    ChDir "C:\Documents and Settings\main\Desktop\temp"
    ActiveWorkbook.SaveAs Filename:= _
    "C:\Documents and Settings\Dan&Stacy\Desktop\temp\Book1.xls", FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    , CreateBackup:=False
    End Sub[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    There are special settings in this code, I use it for a text file and I assign it w/ a timestamp. All can be cut out if you don't need, I am just giving as an example.


    [vba]
    Dim sPath as String
    Dim wb As Workbook
    Dim ws?? As Worksheet
    Set wb = Workbooks("yourworkbookname.xls")
    Set wsEC = Worksheets("sheetname")
    wb.Save
    ws??.Activate
    sPath = "C:\DocsandSetting\Desktop\My Documents\Excel\"

    With ws??
    .SaveAs Filename:=sPath & "yourworkbookname " & _
    Format(Now, "m-dd-yy") & " @ " & Format(Now, "h_mm_ss am/pm") & ".txt", _
    FileFormat:=xlTextMSDOS
    End With
    [/vba]
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  4. #4
    VBAX Mentor jammer6_9's Avatar
    Joined
    Apr 2007
    Location
    Saudi Arabia
    Posts
    318
    Location
    Gotcha
    T-ogether
    E-veryone
    A-chieves
    M-ore


    One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •