+ Reply to Thread
Results 1 to 4 of 4

Save as xlsm file with specific name & specific folder

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-29-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    106

    Save as xlsm file with specific name & specific folder

    Hi all,

    I have this save as pdf code that can "save as" in specific
    folder with specific name :

    Private Sub CommandButton3_Click()
    ' Sub Make_PDF
    ' Create and save .pdf
    Dim pdfName As String, FolderName As String, FullName As String
    pdfName = Range("BI21").Text
    FolderName = Range("BI22").Text
    FullName = ActiveWorkbook.Path & "\" & FolderName & "\" & pdfName & ".pdf"
    If MsgBox("Confirm filename " & FullName & " is correct", vbYesNo + vbQuestion) = vbNo Then Exit Sub
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FullName _
    , Quality:=xlQualityMinimum, IncludeDocProperties:=False, _
    IgnorePrintAreas:=False, OpenAfterPublish:=True
    End Sub
    I try the same code to apply for "xlsm file", but failed :

    Sub save_as_xlsm()
    '
    ' save_as_xlsm Macro
    '
    
    '
    Dim xlsmName As String, FolderName As String, FullName As String
    xlsmName = Range("BI21").Text
    FolderName = Range("BI22").Text
    FullName = ActiveWorkbook.Path & "\" & FolderName & "\" & xlsmName & ".xlsm"
    If MsgBox("Confirm filename " & FullName & " is correct", vbYesNo + vbQuestion) = vbNo Then Exit Sub
        ActiveWorkbookPath.SaveAs Filename:=FullName, _
            FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    
    End Sub
    Can anyone assist me? Thank you in advance

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Save as xlsm file with specific name & specific folder

    Try changing
    ActiveWorkbookPath.SaveAs Filename:=FullName, _
            FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    to

    ActiveWorkbook.SaveAs Filename:=FullName, _
            FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    Alf

  3. #3
    Forum Contributor
    Join Date
    11-29-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    106

    Re: Save as xlsm file with specific name & specific folder

    Thank you so much, it's working

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Save as xlsm file with specific name & specific folder

    You are welcome.

    Thanks for feedback and rep.

    Alf

+ 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] Macro to save file each day to specific folder with date in name
    By sjhf in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2013, 03:24 PM
  2. [SOLVED] macro to save file to specific folder with file name from cell reference
    By mezza89 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-06-2013, 11:32 AM
  3. [SOLVED] Read-Only file needs to be Save As to specific folder with Range Name
    By cariwest in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 08-02-2012, 11:20 AM
  4. VBA Help needed for saving workbook specific folder and file extension ".xlsm"
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-13-2012, 07:50 AM
  5. [SOLVED] How to save file to a specific folder?
    By rko281 in forum Excel General
    Replies: 5
    Last Post: 02-03-2005, 10:30 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