Saving a file with macro
Eliminate Pivot Table Annoyances
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Saving a file with macro

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Posts
    52
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I have a spreadsheet that pulls info from a database. I want to add a macro to save the file, with the file name being the contents of a cell in the sheet. I want to use an input box though, with the contents of that cell as the suggested input(similar to the save as box). That way the user can change it if necessary.

    [ This Message was edited by: DaKen on 2002-02-19 09:08 ]

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Have a look at this:

    Application.GetSaveAsFilename

    Regards,

    Juan Pablo González
    http://www.juanpg.com

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    52
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Can the contents of a cell be placed in the file name input section?

    [ This Message was edited by: DaKen on 2002-02-19 09:33 ]

  4. #4
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    How's this:

    fname = InputBox("Name the file", "Howdy", Range("a1") & ".xls")
    If fname <> "" Then
    ActiveWorkbook.saveas Filename:=fname
    End If

    Cheers,

    Nate

    [ This Message was edited by: NateO on 2002-02-19 11:37 ]

  5. #5
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    The answer to your second question is Yes. And it's better than using an input box:

    Sub save_itas2()
    fname = Application.GetSaveAsFilename _
    (InitialFilename:=Range("a1"), _
    FileFilter:="Excel Files (*.xls),*.xls", FilterIndex:=0, Title:="Save As")
    If fname <> "False" Then
    ActiveWorkbook.saveas Filename:=fname
    End If

    End Sub

    Cheers,

    Nate

  6. #6
    Board Regular
    Join Date
    Feb 2002
    Posts
    52
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    This worked great!! Is there any way to pull the date from a cell that is "=today()" in a format that can be saved as part of the file name?

  7. #7
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Why pull the date from a cell? How's this:

    Sub save_itas3()
    fname = Application.GetSaveAsFilename _
    (InitialFilename:=Range("a1") & " " & WorksheetFunction.Substitute(Date, "/", "_"), _
    FileFilter:="Excel Files (*.xls),*.xls", FilterIndex:=0, Title:="Save As")
    If fname <> "False" Then
    ActiveWorkbook.SaveAs Filename:=fname
    End If
    End Sub


    Cheers,

    Nate

    [ This Message was edited by: NateO on 2002-02-19 20:13 ]

  8. #8
    Board Regular
    Join Date
    Feb 2002
    Posts
    52
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I tried that, but it returns 2/19/2002 which won't work. I'd have to get rid of the "/" somehow!

  9. #9
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Yep, I edited that post. Try the code posted now.

    Cheers,

    Nate

  10. #10
    Board Regular
    Join Date
    Feb 2002
    Posts
    52
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Bingo!!! Thanks a bunch!

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com