+ Reply to Thread
Results 1 to 8 of 8

Save Active Sheet as new workbook, in specific folder, with a filename from a cell value

  1. #1
    Registered User
    Join Date
    05-26-2020
    Location
    Oxford, England
    MS-Off Ver
    Office 365
    Posts
    4

    Save Active Sheet as new workbook, in specific folder, with a filename from a cell value

    Hi.

    I'm pretty new to VBA's and Macros, so apologies if this is a daft request.


    I have a workbook where I would like to save the active worksheet as a new workbook, in a specific C: location and use the value in a cell as the filename.

    I have done this in the past, but it was exporting as a PDF, whereas now I want to save this as an Excel Workbook. The code below is for the working PDF export, can this be tweaked to change the file type or does it need to be brand-new code?


    Private Sub CommandButton2_Click()
    Dim strFileName As String, strC3 As String, strWorksheet As String
    'Set Variable Values
    strC3 = Range("E39").Value
    strWorksheet = ActiveSheet.Name
    strFileName = strC3 & " " & strWorksheet

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
    "C:\LinicModules\" & Range("E50").Value, _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=False
    End Sub


    Thank you in advance

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

    Re: Save Active Sheet as new workbook, in specific folder, with a filename from a cell val

    Try:
    Please Login or Register  to view this content.
    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
    Registered User
    Join Date
    05-26-2020
    Location
    Oxford, England
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Save Active Sheet as new workbook, in specific folder, with a filename from a cell val

    Hi Mumps1

    That was worked perfectly. Thank you so much for your help. Hugely appreciated.

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

    Re: Save Active Sheet as new workbook, in specific folder, with a filename from a cell val

    My pleasure.

  5. #5
    Registered User
    Join Date
    05-26-2020
    Location
    Oxford, England
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Save Active Sheet as new workbook, in specific folder, with a filename from a cell val

    Hi Mumps1. Sorry to bother you. I have just saved the document as an .xltm template (to stop anybody from overwriting this master copy) and now when I use this code, I am getting the pop-up message - Save 'Book1' with references to unsaved documents? - and the new XLSX document isn't being saved.

    Thanks again

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

    Re: Save Active Sheet as new workbook, in specific folder, with a filename from a cell val

    The following steps worked for me:
    -After saving the file as an .xltm template, close it.
    -Click 'File' …. 'New' ….. 'New from existing'
    -Locate the template and open it.
    -Run the macro.

  7. #7
    Registered User
    Join Date
    05-26-2020
    Location
    Oxford, England
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Save Active Sheet as new workbook, in specific folder, with a filename from a cell val

    It's working again now, thank you. But I have noticed that the file size is surprisingly big.

    The Macro Enabled WorkBook is 19MB, when I first used the saveas Macro, because it is only saving the active worksheet, the file size was 64KB. Today, the same saveas Worksheet is 18MB. It doesn't have the hidden tabs or the same embedded Macros, so I can't understand why the file size is so huge. Any thoughts?

    Thank you

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

    Re: Save Active Sheet as new workbook, in specific folder, with a filename from a cell val

    To be honest, I don't know why that would happen. I tried the macro on a dummy file several times and each time it produced a file that was smaller than the macro-enabled workbook as it should. If I could see the 18MB file, I might get a better idea. I don't think that the Forum allows attachments that big. You could try and see what happens. Alternately, you could upload a copy of the file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.

+ 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. [SOLVED] Copy Active Sheet and Save as specific name on cell value in current folder
    By markharris2004 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-21-2019, 09:50 PM
  2. Save active sheet on path and with filename from cell
    By MetteGaga in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-02-2016, 07:33 PM
  3. [SOLVED] History of save process in specific sheet for the active workbook
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-14-2015, 04:39 AM
  4. vba to print active sheet to pdf, auto save in specific folder then mail using outlook
    By lathamashly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-21-2014, 04:57 AM
  5. How to copy Sheet to a new workbook and save to a specific folder
    By moxman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2014, 07:43 PM
  6. [SOLVED] save active sheet in new workbook, naming it as cell value of active sheet
    By arkharova.s in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-18-2014, 06:16 AM
  7. [SOLVED] Save Active Sheet As New Workbook in same folder of the original workbook
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-19-2012, 07:03 PM

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