├── 01_Distribute_Excel_Files_With_Outlook
├── Attachments
│ ├── Canada.xlsx
│ ├── France.xlsx
│ ├── Germany.xlsx
│ ├── Japan.xlsx
│ └── United States of America.xlsx
├── ChatGPT_Prompt.txt
├── Financial_Data.xlsx
└── send_emails.py
├── 02_Automate_PowerPoint
├── ChatGPT_Prompt.txt
├── create_powerpoint.py
└── input
│ ├── Canada.xlsx
│ ├── Germany.xlsx
│ ├── Japan.xlsx
│ └── United States of America.xlsx
├── 03_Create_Interactive_Chart_From_Excel
├── ChatGPT_Prompt.txt
├── Financial_Data.xlsx
└── interactive_chart.py
├── 04_Merge_PDF
├── ChatGPT_Prompt.txt
├── cover
│ ├── 1.pdf
│ ├── 10.pdf
│ ├── 1047.pdf
│ ├── 17.pdf
│ ├── 2.pdf
│ └── 204.pdf
├── draft
│ ├── 1 - Letter of Approval.pdf
│ ├── 10 - Marketing Plan Day 4.pdf
│ ├── 1047 - Closing Statement.pdf
│ ├── 17 - List of Names.pdf
│ ├── 2 - Research Draft F125.pdf
│ └── 204 - Approved Budgeting Plan.pdf
└── merge_pdf.py
├── 05_Write_Emails
└── ChatGPT_Prompt.txt
├── 06_Create_Website
├── .streamlit
│ └── config.toml
├── ChatGPT_Prompt.txt
└── streamlit_app.py
└── README.md
/01_Distribute_Excel_Files_With_Outlook/Attachments/Canada.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/01_Distribute_Excel_Files_With_Outlook/Attachments/Canada.xlsx
--------------------------------------------------------------------------------
/01_Distribute_Excel_Files_With_Outlook/Attachments/France.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/01_Distribute_Excel_Files_With_Outlook/Attachments/France.xlsx
--------------------------------------------------------------------------------
/01_Distribute_Excel_Files_With_Outlook/Attachments/Germany.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/01_Distribute_Excel_Files_With_Outlook/Attachments/Germany.xlsx
--------------------------------------------------------------------------------
/01_Distribute_Excel_Files_With_Outlook/Attachments/Japan.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/01_Distribute_Excel_Files_With_Outlook/Attachments/Japan.xlsx
--------------------------------------------------------------------------------
/01_Distribute_Excel_Files_With_Outlook/Attachments/United States of America.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/01_Distribute_Excel_Files_With_Outlook/Attachments/United States of America.xlsx
--------------------------------------------------------------------------------
/01_Distribute_Excel_Files_With_Outlook/ChatGPT_Prompt.txt:
--------------------------------------------------------------------------------
1 | Here is the chat history for the task: https://chatgpt-static.s3.amazonaws.com/chats/tx61280.html
--------------------------------------------------------------------------------
/01_Distribute_Excel_Files_With_Outlook/Financial_Data.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/01_Distribute_Excel_Files_With_Outlook/Financial_Data.xlsx
--------------------------------------------------------------------------------
/01_Distribute_Excel_Files_With_Outlook/send_emails.py:
--------------------------------------------------------------------------------
1 | import os
2 | import openpyxl
3 | import win32com.client as win32
4 |
5 |
6 | # Get the current working directory
7 | cwd = os.getcwd()
8 |
9 | # Load the Excel workbook
10 | workbook = openpyxl.load_workbook(os.path.join(cwd, "Financial_Data.xlsx"))
11 |
12 | # Select the sheet
13 | sheet = workbook["Email_List"]
14 |
15 | # Get the Outlook application object
16 | outlook = win32.Dispatch('outlook.application')
17 |
18 | # Iterate through the rows in the sheet
19 | for i in range(2, sheet.max_row + 1):
20 |
21 | # Get the attachment file name
22 | attachment = sheet.cell(row=i, column=1).value
23 | attachment_path = os.path.join(cwd, "Attachments", attachment)
24 | if not os.path.exists(attachment_path):
25 | print(f"Attachment {attachment} does not exist")
26 | continue
27 |
28 | # Get the recipient name
29 | recipient_name = sheet.cell(row=i, column=2).value
30 |
31 | # Get the recipient email address
32 | recipient_email = sheet.cell(row=i, column=3).value
33 |
34 | # Get the CC email address
35 | cc_email = sheet.cell(row=i, column=4).value
36 |
37 | # Create a new email
38 | mail = outlook.CreateItem(0)
39 |
40 | # Set the recipient and CC email addresses
41 | mail.To = recipient_email
42 | mail.CC = cc_email
43 |
44 | # Set the email subject
45 | mail.Subject = f"Financial Data: {attachment}"
46 |
47 | # Set the email text
48 | mail.Body = f"Dear {recipient_name},\n\nPlease find the attached financial data for {attachment}.\n\nBest regards,\nYour Name"
49 |
50 | # Add the attachment
51 | mail.Attachments.Add(attachment_path)
52 |
53 | # Open the email in Outlook
54 | mail.Display()
55 |
56 | # close all opened objects
57 | workbook.close()
58 |
--------------------------------------------------------------------------------
/02_Automate_PowerPoint/ChatGPT_Prompt.txt:
--------------------------------------------------------------------------------
1 | Here is the chat history for the task: https://chatgpt-static.s3.amazonaws.com/chats/wj70814.html
--------------------------------------------------------------------------------
/02_Automate_PowerPoint/create_powerpoint.py:
--------------------------------------------------------------------------------
1 | import os
2 | import pandas as pd
3 | import seaborn as sns
4 | import matplotlib.pyplot as plt
5 | from pptx import Presentation
6 | from pptx.util import Inches
7 |
8 | # Determine the directory of the script
9 | script_dir = os.path.dirname(os.path.abspath(__file__))
10 |
11 | input_folder = os.path.join(script_dir, 'input')
12 | charts_folder = os.path.join(script_dir, 'charts')
13 | ppt_file = 'financial_data.pptx'
14 |
15 | # Create the charts folder if it doesn't exist
16 | if not os.path.exists(charts_folder):
17 | os.mkdir(charts_folder)
18 |
19 | # Create a new PowerPoint presentation
20 | prs = Presentation()
21 |
22 | # Iterate through all Excel files in the input folder
23 | for excel_file in os.listdir(input_folder):
24 | if not excel_file.endswith('.xlsx'):
25 | continue
26 |
27 | # Read the financial data from the first worksheet of the Excel file
28 | file_path = os.path.join(input_folder, excel_file)
29 | df = pd.read_excel(file_path, sheet_name=0, usecols="A:P")
30 | df = df.dropna()
31 |
32 | # Group the data by the "Product" column and sum up the "Sales" column
33 | grouped = df.groupby('Product').sum()['Sales']
34 |
35 | # Create a chart using the seaborn library
36 | sns.barplot(x=grouped.index, y=grouped.values)
37 | plt.title(excel_file)
38 | plt.xlabel('Product')
39 | plt.ylabel('Sales')
40 | plt.tight_layout()
41 |
42 | # Save the chart to the charts folder
43 | chart_file = excel_file.replace('.xlsx', '.png')
44 | chart_path = os.path.join(charts_folder, chart_file)
45 | plt.savefig(chart_path)
46 |
47 | # Add a slide to the PowerPoint presentation and insert the chart and title
48 | slide = prs.slides.add_slide(prs.slide_layouts[5])
49 | title = slide.shapes.title
50 | title.text = excel_file.replace('.xlsx','')
51 |
52 | chart_file = chart_path
53 | left = Inches(0.5)
54 | top = Inches(1)
55 | width = Inches(9)
56 | height = Inches(6)
57 | slide.shapes.add_picture(chart_file, left, top, width=width, height=height)
58 |
59 | # Save the PowerPoint presentation in the same directory as the script
60 | ppt_path = os.path.join(script_dir, ppt_file)
61 | prs.save(ppt_path)
62 |
--------------------------------------------------------------------------------
/02_Automate_PowerPoint/input/Canada.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/02_Automate_PowerPoint/input/Canada.xlsx
--------------------------------------------------------------------------------
/02_Automate_PowerPoint/input/Germany.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/02_Automate_PowerPoint/input/Germany.xlsx
--------------------------------------------------------------------------------
/02_Automate_PowerPoint/input/Japan.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/02_Automate_PowerPoint/input/Japan.xlsx
--------------------------------------------------------------------------------
/02_Automate_PowerPoint/input/United States of America.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/02_Automate_PowerPoint/input/United States of America.xlsx
--------------------------------------------------------------------------------
/03_Create_Interactive_Chart_From_Excel/ChatGPT_Prompt.txt:
--------------------------------------------------------------------------------
1 | Here is the chat history for the task: https://chatgpt-static.s3.amazonaws.com/chats/ln81825.html
--------------------------------------------------------------------------------
/03_Create_Interactive_Chart_From_Excel/Financial_Data.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/03_Create_Interactive_Chart_From_Excel/Financial_Data.xlsx
--------------------------------------------------------------------------------
/03_Create_Interactive_Chart_From_Excel/interactive_chart.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 | import plotly.express as px
3 | import os
4 |
5 | try:
6 | # load the data from the "Data" sheet of the "Financial_Data.xlsx" workbook
7 | data = pd.read_excel("Financial_Data.xlsx", sheet_name="Data")
8 |
9 | # check if 'Country' and 'Sales' columns exists in data
10 | if 'Country' not in data.columns or 'Sales' not in data.columns:
11 | raise ValueError("Columns are missing")
12 | # group the data by country and calculate the total sales for each country
13 | sales_by_country = data.groupby("Country")["Sales"].sum().reset_index()
14 |
15 | # create the bar chart
16 | fig = px.bar(sales_by_country, x="Country", y="Sales", title="Financial Data By Country",
17 | labels={"Country": "Country", "Sales": "Total Sales"},
18 | color_discrete_sequence=["#00008B"])
19 |
20 | # save the chart to the same directory as the workbook
21 | fig.write_html("Financial Data By Country.html")
22 |
23 | # display the chart
24 | fig.show()
25 |
26 | except FileNotFoundError as e:
27 | print(f"{e} not found")
28 | except ValueError as e:
29 | print(e)
30 |
--------------------------------------------------------------------------------
/04_Merge_PDF/ChatGPT_Prompt.txt:
--------------------------------------------------------------------------------
1 | Here is the chat history for the task: https://chatgpt-static.s3.amazonaws.com/chats/uf98915.html
--------------------------------------------------------------------------------
/04_Merge_PDF/cover/1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/04_Merge_PDF/cover/1.pdf
--------------------------------------------------------------------------------
/04_Merge_PDF/cover/10.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/04_Merge_PDF/cover/10.pdf
--------------------------------------------------------------------------------
/04_Merge_PDF/cover/1047.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/04_Merge_PDF/cover/1047.pdf
--------------------------------------------------------------------------------
/04_Merge_PDF/cover/17.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/04_Merge_PDF/cover/17.pdf
--------------------------------------------------------------------------------
/04_Merge_PDF/cover/2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/04_Merge_PDF/cover/2.pdf
--------------------------------------------------------------------------------
/04_Merge_PDF/cover/204.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/04_Merge_PDF/cover/204.pdf
--------------------------------------------------------------------------------
/04_Merge_PDF/draft/1 - Letter of Approval.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/04_Merge_PDF/draft/1 - Letter of Approval.pdf
--------------------------------------------------------------------------------
/04_Merge_PDF/draft/10 - Marketing Plan Day 4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/04_Merge_PDF/draft/10 - Marketing Plan Day 4.pdf
--------------------------------------------------------------------------------
/04_Merge_PDF/draft/1047 - Closing Statement.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/04_Merge_PDF/draft/1047 - Closing Statement.pdf
--------------------------------------------------------------------------------
/04_Merge_PDF/draft/17 - List of Names.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/04_Merge_PDF/draft/17 - List of Names.pdf
--------------------------------------------------------------------------------
/04_Merge_PDF/draft/2 - Research Draft F125.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/04_Merge_PDF/draft/2 - Research Draft F125.pdf
--------------------------------------------------------------------------------
/04_Merge_PDF/draft/204 - Approved Budgeting Plan.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sven-Bo/automate-office-tasks-using-chatgpt-python/1bb09f32a47af62787077c238d79fab175fa3429/04_Merge_PDF/draft/204 - Approved Budgeting Plan.pdf
--------------------------------------------------------------------------------
/04_Merge_PDF/merge_pdf.py:
--------------------------------------------------------------------------------
1 | import os
2 | from PyPDF2 import PdfMerger # pip install PyPDF2
3 |
4 | def merge_pdfs(cover_folder, draft_folder, output_folder):
5 | # Create the output folder if it doesn't exist
6 | if not os.path.exists(output_folder):
7 | os.mkdir(output_folder)
8 |
9 | # Get a list of PDFs in the cover and draft folders
10 | cover_pdfs = [f for f in os.listdir(cover_folder) if f.endswith('.pdf')]
11 | draft_pdfs = [f for f in os.listdir(draft_folder) if f.endswith('.pdf')]
12 |
13 | # Iterate through the cover PDFs
14 | for pdf in cover_pdfs:
15 | # Get the numeric key of the PDF
16 | key = pdf.split('.')[0]
17 |
18 | # Find the matching draft PDF with the same key
19 | matching_draft = [f for f in draft_pdfs if key in f][0]
20 |
21 | # Create a PdfMerger object
22 | merger = PdfMerger()
23 |
24 | # Add the cover and draft PDFs to the merger
25 | merger.append(f'{cover_folder}/{pdf}')
26 | merger.append(f'{draft_folder}/{matching_draft}')
27 |
28 | # Write the merged PDF to the output folder
29 | merger.write(f'{output_folder}/{matching_draft}')
30 |
31 | print(f'Merged {len(cover_pdfs)} PDFs to {output_folder}')
32 |
33 | # Example usage
34 | merge_pdfs('cover', 'draft', 'output')
35 |
--------------------------------------------------------------------------------
/05_Write_Emails/ChatGPT_Prompt.txt:
--------------------------------------------------------------------------------
1 | Here is the chat history for the task: https://chatgpt-static.s3.amazonaws.com/chats/qq32478.html
--------------------------------------------------------------------------------
/06_Create_Website/.streamlit/config.toml:
--------------------------------------------------------------------------------
1 | [theme]
2 | # Primary accent color for interactive elements.
3 | primaryColor = "#E694FF"
4 |
5 | # Background color for the main content area.
6 | backgroundColor = "#00172B"
7 |
8 | # Background color used for the sidebar and most interactive widgets.
9 | secondaryBackgroundColor = "#0083B8"
10 |
11 | # Color used for almost all text.
12 | textColor = "#FFF"
13 |
14 | # Font family for all text in the app, except code blocks. One of "sans serif", "serif", or "monospace".
15 | # Default: "sans serif"
16 | font = "sans serif"
--------------------------------------------------------------------------------
/06_Create_Website/ChatGPT_Prompt.txt:
--------------------------------------------------------------------------------
1 | Here is the chat history for the task: https://chatgpt-static.s3.amazonaws.com/chats/aa18460.html
--------------------------------------------------------------------------------
/06_Create_Website/streamlit_app.py:
--------------------------------------------------------------------------------
1 | import streamlit as st
2 |
3 | st.set_page_config(page_title="Automate Boring Office Tasks with ChatGPT and Python",
4 | page_icon=":robot:",
5 | layout="centered")
6 |
7 | st.title("🤖 Automate Boring Office Tasks with ChatGPT and Python")
8 |
9 | st.markdown("Learn how to use ChatGPT and Python to automate tasks such as distributing Excel files with Outlook, creating interactive charts from Excel, merging PDFs, and more.")
10 |
11 | st.markdown("""
12 | 👉 Distribute Excel Files With Outlook
13 |
14 | 👉 Automate PowerPoint
15 |
16 | 👉 Create Interactive Charts From Excel
17 |
18 | 👉 Merge PDFs
19 |
20 | 👉 Write E-Mails
21 |
22 | 👉 How I created this website
23 | """, unsafe_allow_html=True)
24 |
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Automate Boring Office Tasks with ChatGPT and Python
2 | Tired of spending hours on tedious office tasks? In this video, I'll show you how to use ChatGPT and Python to automate some of those boring tasks. We'll be looking at automating Outlook, creating PowerPoint presentations, generating charts from Excel data, and manipulating PDFs.
3 | First up, we'll go over how to use ChatGPT and Python to automate tasks in Outlook like sending emails to a list of recipients pulled from an Excel file. Then we'll move on to using ChatGPT and Python to create slides and add text and images to them for PowerPoint presentations.
4 | Next, we'll look at how to use ChatGPT and Python to create interactive charts based on data from an Excel file. And lastly, we'll cover how to use ChatGPT and Python to automate PDF tasks like merging multiple documents.
5 | As a bonus, we'll also take a look at how to use ChatGPT to write emails for you so you don't have to.
6 | Overall, this video will give you a good idea of how you can use ChatGPT and Python to automate some of those repetitive tasks that take up so much of your time.
7 |
8 | ## Live website with all the ChatGPT prompts
9 | https://automate-office-chatgpt.streamlit.app/
10 |
11 | ## Video Tutorial
12 | [](https://youtu.be/mCk4Rabkmjc)
13 |
14 |
15 |
16 |
17 | ## 🤓 Check Out My Excel Add-ins
18 | I've developed some handy Excel add-ins that you might find useful:
19 |
20 | - 📊 **[Dashboard Add-in](https://pythonandvba.com/grafly)**: Easily create interactive and visually appealing dashboards.
21 | - 🎨 **[Cartoon Charts Add-In](https://pythonandvba.com/cuteplots)**: Create engaging and fun cartoon-style charts.
22 | - 🤪 **[Emoji Add-in](https://pythonandvba.com/emojify)**: Add a touch of fun to your spreadsheets with emojis.
23 | - 🛠️ **[MyToolBelt Add-in](https://pythonandvba.com/mytoolbelt)**: A versatile toolbelt for Excel, featuring:
24 | - Creation of Pandas DataFrames and Jupyter Notebooks from Excel ranges
25 | - ChatGPT integration for advanced data analysis
26 | - And much more!
27 |
28 |
29 |
30 | ## 🤝 Connect with Me
31 | - 📺 **YouTube:** [CodingIsFun](https://youtube.com/c/CodingIsFun)
32 | - 🌐 **Website:** [PythonAndVBA](https://pythonandvba.com)
33 | - 💬 **Discord:** [Join our Community](https://pythonandvba.com/discord)
34 | - 💼 **LinkedIn:** [Connect with me](https://www.linkedin.com/in/sven-bosau/)
35 | - 📸 **Instagram:** [Follow me](https://www.instagram.com/codingisfun_official/)
36 |
37 | ## Support My Work
38 | Love my content and want to show appreciation? Why not [buy me a coffee](https://pythonandvba.com/coffee-donation) to fuel my creative engine? Your support means the world to me! 😊
39 |
40 | [](https://pythonandvba.com/coffee-donation)
41 |
42 | ## Feedback
43 | Got some thoughts or suggestions? Don't hesitate to reach out to me at contact@pythonandvba.com. I'd love to hear from you! 💡
44 | 
45 |
--------------------------------------------------------------------------------