+ Reply to Thread
Results 1 to 6 of 6

SaveAs alert when change xlsm to xlsx

Hybrid View

  1. #1
    Registered User
    Join Date
    07-10-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    3

    SaveAs alert when change xlsm to xlsx

    Hi all.

    So I am very new to VBA/Macros most of my programming experience is in scripting languages like python. I have looked at previous post but nothings seems to solve my problem.

    I am currently setting up an excel sheet that contains a fair amount of macros as to guide end-users when the sheet is filled in. Finally I want the sheet to be saved as a normal xlsx by the click of a bottom on the sheet.

    I have a macros button that points to this :

    Sub SaveAS()
    ActiveWorkbook.Application.EnableEvents = False
    ActiveWorkbook.Application.DisplayAlerts = False
    ActiveWorkbook.SaveAS Filename:="New_Sheet.xlsx", FileFormat:=52, ConflictResolution:=xlLocalSessionChanges
    MsgBox "Your Sample Sheet has been saved"
    ActiveWorkbook.Application.DisplayAlerts = True
    ActiveWorkbook.Application.EnableEvents = True
    End Sub
    This works but it still results in an alert that when saving as xlsx that macros will be removed. I was under the impression that Application.DisplayAlerts = False would disable the alerts and the SaveAs would just "happen"

    Help would be appreciated

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: SaveAs alert when change xlsm to xlsx

    You might be better creating a new workbook and copying the sheets from your macro workbook across to this and saving the new workbook as the XLSX.
    Martin

  3. #3
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: SaveAs alert when change xlsm to xlsx

    One more thing..

    FileFormat:=52
    is used to Open XML Workbook Macro Enabled
    You may try FileFormat:=-4143
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  4. #4
    Registered User
    Join Date
    07-10-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: SaveAs alert when change xlsm to xlsx

    Hi Altair,

    Use this code, I hope it might help you

    Sub SaveAsAndClose()

    ActiveWorkbook.SaveAs "finaloutput.xlsx"
    ActiveWorkbook.Close

    End Sub

  5. #5
    Registered User
    Join Date
    07-10-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: SaveAs alert when change xlsm to xlsx

    Thanks for the replies.

    Mrice I have tried your suggestions with copy the sheet to new workbook but its seems to be copying the macros with? Any suggestions on how I can copy the entire sheet without the macros? I might mentioned that the sheet contains formatting (colors etc. I will like to have copy as well)

    Thanks

  6. #6
    Registered User
    Join Date
    07-10-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: SaveAs alert when change xlsm to xlsx

    This is what I did in the end and it worked for me....

    Sub SaveAS()
    Dim wbO As Workbook
    Dim wbI As Workbook
    Dim wsI As Worksheet
    Dim wsO As Worksheet
    
    Set wbI = ThisWorkbook
    Set wsI = wbI.Sheets("Sheet1")
    Set wbO = Workbooks.Add
    
    strPath = wbI.Path
    
    With wbO
        Set wsO = wbO.Sheets("Sheet1")
        .SaveAS Filename:=strPath & ":" & "Test.xlsx"
        wsI.Cells.Copy
        wsO.Range("A1").PasteSpecial Paste:=xlPasteAll
        End With
    Dim pic As Shape
    For Each pic In wsI.Shapes
       If pic.Type = msoPicture Then
            'MsgBox pic.TopLeftCell.Address
            pic.Copy
            With wsO
            If pic.Name = "Picture 4" Then
                .Range("B1").Select
                .Paste
            Else
            .Range("C1").Select
            .Paste
            End If
            End With
       End If
    Next pic
    
    With wsO
        Cells.Select
        Selection.Locked = True
        .Protect Password:="btp"
    End With
    
    Workbooks("Test.xlsx").Close SaveChanges:=True
    
    End Sub

+ Reply to Thread

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