Hello,
I have a code that saves a copy of a template in several files. Its work really well but it doesn't keep the margin setting on the saved document. When we have to go in and reprint that document we always have to reset the margins or it will print on multiple pages.
How can this code be modified to save margins as they are set in the template?
Code
Public Sub Save_Receipt()
Application.ScreenUpdating = False
GetReceiptNumberRun
SendReceiptToMaster
Dim SaveAsFileName As Variant
Dim newWorkbook As Workbook
SaveAsFileName = "C:\Users\Administrator\Desktop\Shared\Receipts\" & Range("I10").Value & ".xlsx"
Set newWorkbook = Workbooks.Add(XlWBATemplate.xlWBATWorksheet)
ThisWorkbook.Worksheets("Receipt").Copy Before:=newWorkbook.Worksheets(1)
'Tidy up copied Invoice sheet
With newWorkbook.Worksheets(1)
'Convert formulas to their values
.Range("I11").Value = .Range("I11").Value 'Date
.Range("J16:J48").Value = .Range("J16:J48").Value 'Totals
.Range("H41:H46").Value = .Range("H41:H46").Value 'Hiden formulas
.Range("B1").Value = .Range("B1").Value 'Hiden Formula
'Delete data validation dropdowns
.Range("B10").Validation.Delete
.Range("I12").Validation.Delete
.Range("F42").Validation.Delete
'Delete unwanted columns, including hidden lookup table
.Columns("K:AZ").Delete
End With
'Suppress all Excel warnings: deleting sheet; saving as macro-free workbook; file already exists
Application.DisplayAlerts = False
'Delete empty sheet
newWorkbook.Sheets(2).Delete
'Save new workbook in xlsx format
newWorkbook.SaveAs SaveAsFileName, xlOpenXMLWorkbook
newWorkbook.Close False
PrintReceipt
'Clear Receipt
Clear_Receipt
'Reenable Excel warnings
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Display More