Results 1 to 10 of 10

Save a Macro Enabled Template to a custom location with a custom file name.

Threaded View

  1. #1
    Registered User
    Join Date
    01-22-2012
    Location
    DiLLi
    MS-Off Ver
    Excel 2010
    Posts
    16

    Save a Macro Enabled Template to a custom location with a custom file name.

    Hi
    I wish to save a macro enabled template file to a macro enabled file in D:\Invoice\2012\ with a file name equivalent to the value of cell k3 in sheet 1.
    I tried the following macro but ended up with a error

    Sub saveFileMacro()
    FullFileName = Application.GetSaveAsFilename("D:\Invoice\2012\" & Format(Range("K3").Value) & ".xlsm", _
        "Excel Macro-Enabled Workbook (*.xlsm),*.xlsm", 2, "Save File As")
    If FullFileName <> vbNullString Then
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:= _
            FullFileName, FileFormat:= _
            xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWorkbook.Close
    Else
    MsgBox "File not saved"
    End If
    End Sub
    It works only till the "save as" screen and once I press save, it shows error "Runtime error '1004'. This extension cannot be used with selected file type and so on..
    Originally I got this macro from http://www.excelforum.com/excel-prog...-template.html, customized it a little based on my requirement but still ended up with an error.

    A little help would be much appreciated.

    Thanks
    Anand
    Last edited by andcha; 01-27-2012 at 01:50 PM.

Thread Information

Users Browsing this Thread

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

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