+ Reply to Thread
Results 1 to 4 of 4

VBA to name, save and close a file

  1. #1
    Forum Contributor
    Join Date
    07-27-2012
    Location
    Somerset, Kentucky
    MS-Off Ver
    Excel 2007
    Posts
    123

    VBA to name, save and close a file

    I have the code below. What I want it to also do, is close the file. ?


    Private Sub cmbComplete_Click()

    usfFinished.Hide

    Dim dt As String, wbNam As String
    wbNam = "EmpSatSur"
    dt = Format(CStr(Now), "yyyymmddhhmmss")
    ActiveWorkbook.SaveAs Filename:=wbNam & dt
    End Sub

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,833

    Re: VBA to name, save and close a file

    Add
    Please Login or Register  to view this content.
    after the "SaveAs" line.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    07-27-2012
    Location
    Somerset, Kentucky
    MS-Off Ver
    Excel 2007
    Posts
    123

    Re: VBA to name, save and close a file

    This is saving it in the "Documents" folder. I would prefer it to save in its present location. Any help with that?

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,833

    Re: VBA to name, save and close a file

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Script/macro to save a copy as tab delimited text file and then close original file
    By Merlin803 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-02-2015, 01:34 PM
  2. Problem With Open File and Save File With Saveas and then close the File
    By John Vieren in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-27-2013, 12:53 AM
  3. Replies: 1
    Last Post: 10-25-2013, 06:10 PM
  4. Replies: 1
    Last Post: 10-01-2012, 11:46 PM
  5. How to: Open file, format data, save file, close file and repeat.
    By thexeber in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-11-2010, 12:56 PM
  6. Replies: 0
    Last Post: 08-30-2006, 05:58 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1