+ Reply to Thread
Results 1 to 4 of 4

VBA to add Save as Function

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    VBA to add Save as Function

    Hello,

    I have below VBA code which moves sheets from active workbook. How to add a code which would open a dialog box allowing me choose Save as.

    Sub CopySheet()
        Dim varLinks
        Dim strFileName As String
        strFileName = ActiveWorkbook.Path & ActiveSheet.Range("A1").Value & ActiveSheet.Name & ".xml"
        Sheets(Array("Overview", "Create ", "Edit Assign ", "Request Default", "Assign ", "Assign Cos")).Move ' Creates the new workbook AND DELETES THE OLD SHEET
         
         '=======================================================
         'Sometimes you need to kill the links.  Omit this block if this is not an issue
        varLinks = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)
        If IsArray(varLinks) Then
            For i = LBound(varLinks) To UBound(varLinks)
                ActiveWorkbook.BreakLink Name:=varLinks(i), Type:=xlLinkTypeExcelLinks
            Next i
        End If
         'End Link killing code
         '=======================================================
         
        ActiveWorkbook.SaveAs strFileName
        ActiveWorkbook.Close False
        
        
    End Sub
    Keep the Forum clean :


    1. Use [ code ] code tags [ /code ]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    2. Show appreciation to those who have helped you by clicking * Add Reputation below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA to add Save as Function

    activeworkbook.saveas(application.getsaveasfilename)

  3. #3
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: VBA to add Save as Function

    Thx.. It is working.. But it is saving file as some unopened format. How to save it in xml format?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA to add Save as Function

    ActiveWorkbook.SaveAs Application.GetSaveAsFilename, FileFormat:=xlXMLSpreadsheet
    ?

+ 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. Stopping the save function...until a user has clicked "save as".
    By ExcelToyney in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2010, 07:36 AM
  2. [SOLVED] Save As Function
    By Hlewis in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-03-2006, 04:10 PM
  3. Save and Save as Function gone
    By Michael S. in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2005, 02:05 PM
  4. Remove or Disable the Save Function and Keep the Save As
    By topkick in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-23-2005, 08:38 PM
  5. Save as vba function
    By alanford in forum Excel General
    Replies: 5
    Last Post: 02-20-2005, 06:07 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