Forum Discussion
HELP WITH A MACRO
It seems like there are some typos and errors in your code that might be causing the issues you are facing. Here are some suggestions to help you fix them:
In the SaveInv() sub, you are trying to delete all shapes in the copied sheet except for pictures. However, the syntax for the If statement is incorrect. Change If shp.Type <> msoPicture Then shp.Delete to If shp.Type <> msoPicture Then shp.Delete End If.
In the SaveAspdf() sub, the path variable for saving the PDF does not include a backslash at the end of the folder path. Change path = "C:\Users\joann\OneDrive - name\folder\folder\folder\folder\Invoices" to path = "C:\Users\joann\OneDrive - name\folder\folder\folder\folder\Invoices\".
In the EmailAspdf() sub, you have a typo in the path variable. Remove the extra space before the opening single quote in the path string. Change path = " 'C:\Users\joann\OneDrive - name\folder\folder\folder\folder\Invoices" to path = "C:\Users\joann\OneDrive - name\folder\folder\folder\folder\Invoices\".
In the EmailAspdf() sub, you are missing a closing parenthesis in the line nextrec.Offset(0, = Now. Change it to nextrec.Offset(0, 4) = Now.
In the EmailAspdf() sub, you are not setting the amt and dt_issue variables before exporting the PDF and updating the invoice record. Add the following lines before exporting the PDF:
amt = Range("E38")
dt_issue = Range("B4")
- In the EmailAspdf() sub, you are not updating the invoice record for the date and time the email was sent. Add the following line after updating the invoice record for the PDF:
nextrec.Offset(0, 5) = Now
With these changes, your code should work as expected. Let me know if you have any further questions or issues.