Consulting

Results 1 to 5 of 5

Thread: VBA Code to change file format .xlm to .xlxs

  1. #1

    VBA Code to change file format .xlm to .xlxs

    I'm working on a project that requires MACROS, but is also required to be saved as *.xlxs to run in the database I'm using. Is there a way to build a MACRO to achieve this? I realize that .xls and .xlsx both are created to protect against MACROS, so I understand if this is not realistic.

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,715
    Location
    I'd write a macro (which has to be in the XLSM) that writes a COPY of the XLSM workbook (or just the desired worksheets) to a new workbook which is then saved as a XLSX
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    That's a great way to think about it!

    This is what I found on another forum-- I'll try this just changing my filename format.

    Sub SaveAs()
     
        Dim FName           As String
        Dim FPath           As String
     
        FPath = "G:\Exceptions\"
        FName = "Exceptions" & Format(Date, "ddmmyy") & ".xls"
     
        Sheets("DataSort").Copy
        ThisWorkbook.Sheets("Sheet1").SaveAs Filename:=FPath & "\" & FName
     
    End Sub
    Last edited by Paul_Hossler; 06-09-2017 at 04:26 PM.

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,715
    Location
    1. The [#] icon will insert [ CODE ] ....... [/ CODE ] markers for you to paste the macro between; does some formatting and makes it easier to read

    2. You can use the macro recorder to give you something to work with as a starting point


    Option Explicit
    Sub Macro1()
        
        Sheets("Sheet1").Select
        Sheets("Sheet1").Copy
        ActiveWorkbook.SaveAs Filename:="C:\Users\USER\Documents\test_09062017.xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
        ActiveWindow.Close
    End Sub
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    Great, thank you so much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •