Excel User Group
Microsoft Excel blogs, forums, files. Read, ask questions, provide answers.

acknowledging " SAVE AS " AUTOMATICALLY

Latest post Wed, Jun 11 2008 4:45 PM by Nick Hodge. 1 replies.
  • Wed, Jun 11 2008 11:37 AM

    • venu
    • Top 75 Contributor
    • Joined on Tue, Jun 3 2008
    • Posts 4
    • Points 100

    acknowledging " SAVE AS " AUTOMATICALLY

     How do i make this macro to automatically save the file without the user ackenowledging with  " OK" . I want the user to skip this event so that excel shutsdown automatically after saving the file with a time stamp on it.

    Your contribution is highly appreciated........

    Venu

     

    Private Sub Workbook_Open()

           

    Application.DisplayAlerts = False
    Range("A1:O107").Select
    ActiveSheet.PageSetup.PrintArea = "$A$1:$O$107"
    Application.ActivePrinter = "\\FRE-AMERICA-DC1\FRE-DELL1815-KINGSHFT on Ne01:"
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
            "\\FRE-AMERICA-DC1\FRE-DELL1815-KINGSHFT on Ne01:", Collate:=True




    ' Save file name and path into a variable
        template_file = ActiveWorkbook.FullName
     

        fileSaveName = Application.GetSaveAsFilename( _
        InitialFileName:="C:\temp\gulfstar_" + VBA.Strings.Format(Now(), "ddmmyyyy  HH MM AMPM") + ".txt", _
        fileFilter:="Text Files (*.txt), *.txt")
       
       

    ' Save file as .txt TAB delimited
        ActiveWorkbook.SaveAs Filename:= _
            fileSaveName, FileFormat:=xlText, _
            CreateBackup:=False

       
        file_name_saved = ActiveWorkbook.FullName
        MsgBox "Your Acct Rec upload file has been successfully created at: " & vbCr & vbCr & file_name_saved
       
       
    ' Go back to excel format after TAB delimited file has been created and saved
        ActiveWorkbook.SaveAs Filename:= _
            template_file, FileFormat:= _
            xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
            , CreateBackup:=False
         Application.Quit
         Application.DisplayAlerts = True


           
    End Sub


    Filed under:
    • Post Points: 21
  • Wed, Jun 11 2008 4:45 PM In reply to

    • Nick Hodge
    • Top 10 Contributor
    • Joined on Sun, Dec 23 2007
    • Southampton
    • Posts 242
    • Points 4,017
    • MVP

    Re: acknowledging " SAVE AS " AUTOMATICALLY

    Venu

    This should get you a little further along the road. I have killed the formulas (links) on the original sheet and then moved it to a new workbook. Saved that and closed it (no links). Then I take the original file and make Excel think it is saved (.Saved=True) and closed the application. (make sure I am copying the full extend of the report and links). Here is the code. (Test it in a copy of the workbook)

     

    Private Sub Workbook_Open()
    Dim wksCurrent As Worksheet
    Dim wbNew As Workbook
    
    Set wksCurrent = ThisWorkbook.Worksheets("FALSE")
    
    With wksCurrent
        .PageSetup.PrintArea = "$A$1:$O$107"
        .PrintOut Copies:=1, ActivePrinter:= _
            "\\FRE-AMERICA-DC1\FRE-DELL1815-KINGSHFT on Ne01:", Collate:=True
        With .Range("A1:Q112")
            .Copy
            .PasteSpecial (xlPasteValuesAndNumberFormats)
        End With
    End With
    
    wksCurrent.Move
    
    Set wksCurrent = Nothing
    Set wbNew = ActiveWorkbook
    
    With wbNew
        .SaveAs ("C:\temp\gulfstar_" & Format(Now(), "ddmmyyy hhmm AMPM") & ".xls")
        .Close
    End With
    
    
    Set wbNew = Nothing
    
    ThisWorkbook.Saved = True
    Application.Quit
    End Sub

     

    Regards
    Nick Hodge
    Microsoft MVP, Excel
    Southampton, UK

    • Post Points: 5
Page 1 of 1 (2 items) | RSS
Copyright Excel User Group and the relevant contributors, 2008. All Trade Marks acknowledged. This site is a peer-to-peer site and NOT affiliated in any way to Microsoft Corp. All rights reserved.