Table = document.add_table(rows=1, cols=4) P2 = document.add_paragraph('Please find attached invoice for your recent purchase of ') Enjoy! from docx import Documentĭef make_client_invoice(name, email, product, unit, price):ĭocument.add_picture('brand_logo.png', width=Inches(1)) You can use a loop to send invoices one by one or build them with other processes. It’s your turn to try putting it together. Now I offer the three functions for the three steps of the invoicing system. The best part – no credentials or passwords are required, the win32com will just interact with Outlook with your existing settings. As long as we have previously logged into our Outlook App, it’s good to go. It appears that we don’t even need to have Outlook App open to send an email using Python. To add an attachment, simply pass in the file location similar to line 8. The wdFormatPDF = 17 is likely a convention used by VBA, check this list on other file type options we can save to. Replace the Word with Excel, then you’ll have an Excel instance! ("Word.Application") will create a MS Word instance/object inside Python. The code below takes an input file path src, then converts and saves a pdf to file path dst. To convert Word (.docx) to PDF format, we essentially open the document using win32com, then Save As PDF format. It can control the Office Suite of apps for example. The win32com is a great library that allows us to control lots of things in the Windows operating system. Note the difference below: pip install pywin32 We’ll use the pywin32/ win32com library, this one also got a weird naming between installation name and library name. Now we have our invoice in Word, let’s convert it to PDF since that’s the standard format for business documents. docx file Convert MS Word Document To PDF Format Let’s test the function, looks good! make_client_invoice('Elon Musk', 9',10, 1000000)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |