Consulting

Results 1 to 2 of 2

Thread: can not be saved in a macro-free workbook

  1. #1
    VBAX Regular
    Joined
    Aug 2016
    Posts
    12
    Location

    can not be saved in a macro-free workbook

    can someone tell me whats wrong with this code
    i keep getting a error saying
    can not be saved in a macro-free workbook.
    it was working fine a while ago


    Sub copysave()
    'copy invoice to a new workbook
    ActiveSheet.copy
    newfn = "k:\INVOICES BACKUP\ALL\" & Range("e4").Value & "." & Range("a10") & ".xlsx"
    ActiveWorkbook.SaveAs newfn, FileFormat:=xlOpenXMLWorkbook
    ActiveSheet.PrintOut
    ActiveWorkbook.Close
    
    
    'copy invoice to a new workbook
    ActiveSheet.copy
    newfn = "C:\Users\roger\Documents\aaa\" & Range("e4").Value & "." & Range("a10") & ".xlsx"
    ActiveWorkbook.SaveAs newfn, FileFormat:=xlOpenXMLWorkbook
    ActiveWorkbook.Close
    Range("e4").Value = Range("e4").Value + 1
    Range("a18:d30").ClearContents
    Range("E3").ClearContents
    Range("a10").ClearContents
    ActiveWorkbook.Close
    End Sub
    Last edited by Bob Phillips; 06-11-2017 at 05:56 AM. Reason: Added code tags

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    If there are macros etc. in the workbook it needs to be saved as .xlsm
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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