+ Reply to Thread
Results 1 to 2 of 2

.xltm into excel file which still contains the macro

Hybrid View

  1. #1
    Registered User
    Join Date
    09-18-2013
    Location
    bellingham
    MS-Off Ver
    Excel 2010
    Posts
    1

    .xltm into excel file which still contains the macro

    I have an excel file which have macros , and in its vb code the file is saved as .xltm file but i want to change it to some other format which would containd the macros .

    my code behind the save and close button is :
    Sub Save_As()
        If MsgBox("Are you sure you want to Exit now?", vbYesNo) = vbNo Then Exit Sub
        ActiveSheet.Unprotect Password:="C0g!
        For Each ws In ThisWorkbook.Worksheets
            With ws.UsedRange
                .Copy
            .Cells(1, 1).PasteSpecial Paste:=xlPasteValues
        End With
    Next ws
    
    Application.CutCopyMode = False
    
        ActiveSheet.Shapes("UpdateTemplate").Delete
        ActiveSheet.Shapes("SaveClose").Delete
        Range("F18").Select
        ActiveWorkbook.SaveAs Filename:="O:\QA Files\Pending Review\" & Range("D12") & "_" & "BagGla" & "_" & Range("D6") & "_" & Format(Now(), "YYYYMMDDhhmmss") & ".xltm", FileFormat:=53
    
        If Workbooks.Count = 1 Then
            Application.Quit
        Else
            ActiveWorkbook.Close savechanges:=False
        End If
               
    End Sub
    PLease help me finding a way in which i can save this .xltm file as another file(any format ) which should contains all the macros and data which this file would have.Thanks

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: .xltm into excel file which still contains the macro

    Hi, hahmed,

    maybe use the macro enabled format xlsm for saving:
    ActiveWorkbook.SaveAs Filename:="O:\QA Files\Pending Review\" & Range("D12") & "_" & "BagGla" & "_" & Range("D6") & "_" & Format(Now(), "YYYYMMDDhhmmss") & ".xlsm", FileFormat:=52
    You may also try using xlsb with FileFormat 50.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ 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. [SOLVED] Pivot table loses reference in xltm
    By Sir_Casm in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 07-09-2013, 11:01 AM
  2. Use of XLTM file
    By jcb267 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-16-2012, 02:35 PM
  3. Custom File Name At Start-up Using Macro-Enabled Template Format (.XLTM) (VBA)
    By engineerchange in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-18-2012, 08:48 AM
  4. macro prompts immediately to open a file once the Excel file with the macro is opened
    By jhmayor03 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-03-2012, 10:00 AM
  5. Replies: 3
    Last Post: 09-11-2009, 03:38 AM

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