Invoice macro issue

rmcnamee

New Member
Joined
Nov 23, 2014
Messages
4
Hello all. I created an invoice using the steps detailed in Podcast 1505 and everything works as planned; however, I'm getting a pop message each time I go to save the invoice. Below is the macro I'm using that I pulled from the message boards:

Sub SaveInvoiceBothWaysAndClear()
Dim NewFN As Variant
' Create the PDF First
NewFN = "T:\Outside Contract\PDF Invoices\Inv#" & Range("h3").Value & Range("i3").Value & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=NewFN, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
' Next, Save the Excel File
ActiveSheet.Copy
NewFN = "T:\Outside Contract\Excel Invoices\Inv#" & Range("h3").Value & Range("i3").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
' Increment the invoice number
Range("i3").Value = Range("i3").Value + 1
' Clear out the invoice fields
Range("A12:I23").ClearContents
Range("h3").ClearContents
End Sub

Attached is the error message I'm getting. I just want the file to save as a regular spreadsheet and generate a blank invoice. Thanks in advance for any help!
 

Attachments

  • Invoice error.jpg
    Invoice error.jpg
    69.6 KB · Views: 17

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

AC PORTA VIA

Board Regular
Joined
Apr 9, 2016
Messages
155
Office Version
  1. 365
Platform
  1. Windows
you could try to remove FileFormat:=xlOpenXMLWorkbook
and just use ActiveWorkbook.SaveAs NewFN
 

Alex Blakenburg

MrExcel MVP
Joined
Feb 23, 2021
Messages
4,985
Office Version
  1. 365
Platform
  1. Windows
Try turning alerts off before the save and back on after the save.
The message is telling you that you are saving the current workbook with macros (.xlsm) to a non-macro enabled format (.xlsx), which will remove the macros from the newly created "save as" file.

VBA Code:
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
Application.DisplayAlerts = True
 

Forum statistics

Threads
1,175,456
Messages
5,897,524
Members
434,659
Latest member
Fityi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top