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: 19

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
you could try to remove FileFormat:=xlOpenXMLWorkbook
and just use ActiveWorkbook.SaveAs NewFN
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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
Back
Top