Hello All,
I am new to VBA. I have been following the TeachExcel course, and I have to admit that most of the time you may as well be speaking Swahili.
I am using MacOS and I am unable to save an invoice as a PDF using a concatenation of the invoice number and the customer name. I keep getting "Run Time Error 1004 Application - defined or Object - defined error. (this code I entered by hand)
I tried recording a macro and at the prompt I gave the file name as the invoice number and the customer name and it saved perfectly. I then altered the macro by incrementing the invoice number by one and I received the same error.
I am completely lost and would appreciate any help that anyone is able to provide.
Attached is a copy of the file and also a copy of the Save Invoice macro.
Thank you.
Sub SaveInvoice()
'
' SaveInvoice Macro
'
invno = Range("InvNumber")
custname = Range("Customer")
fname = invno & " - " & custname & ".pdf"
MsgBox (fname)
' Check if invoice has been previously saved
'
ChDir "/Users/Guest/Documents/Projects/Georgina Invoice/"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
FileName:=fname, _
Quality:=xlQualityMinimum, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
opeanafterpublish:=False
'Set SavedFlag
Range("FlagSaved").Value = "Yes"
Range("ItemName").Select
End Sub