The future of
automation!
VBA Office Scripts
by ChatGPT
AUTOMATICALLY INSTERT
TABLE OF CONTENTS
SWIPE
By Mynda Treacy | Microsoft MVP © My Online Training Hub
VBA is the OLD way to Automate Excel
VBA’s limitation is it’s tied
to the desktop. VBA cannot
and never will be able to
execute in Excel online.
SWIPE
What are Office Scripts
Record and replay
SWIPE
actions to AUTOMATE
BORING tasks.
The Problem
Sometimes you need a more complex
script than the recorder can handle. For
that you need JavaScript or TypeScript
skills. I DON’T HAVE THESE SKILLS!
SWIPE
The Solution - ChatGPT
Ask ChatGPT to
write the script.
SWIPE
The Scenario
Insert a new sheet in the
file containing a table of
contents with hyperlinks to
each sheet.
SWIPE
The Prompt
"Write an Excel Office Script to generate a
new Table of Contents sheet called "TOC"
that contains a hyperlink to each sheet in
the current file. If there is already a sheet
called "TOC", delete it before creating the
new sheet. Start the table of contents
hyperlinks in cell B3. Format the hyperlinks
in blue font with an underline. Place a
heading in cell B1 of the "TOC" sheet with
the text "Table of Contents" in black bold
font, size 18. Hide the gridlines on the “TOC”
sheet. Annotate the script to explain what
each step in the script does."
SWIPE
The Response
SWIPE
Download Script
Inserting the Script in Excel
Open Excel Desktop or Excel Online
Paste code
from ChatGPT
SWIPE
Using the Script
SWIPE
Click Run
The Result
New sheet with
Table of Contents
and hyperlinks to SWIPE
each sheet.
Office Scripts Requirements
Office Scripts is available to Excel users with the following:
1. Excel for Windows (version 2210 or higher), Excel for
Mac, or Excel Online.
2. OneDrive for Business.
3. Any commercial or educational Microsoft 365 license
with access to the Microsoft 365 Office desktop apps,
such as:
• Office 365 Business or Business Premium
• Office 365 ProPlus or ProPlus for Devices
• Office 365 Enterprise E3 or E5
• Office 365 A3 or A5
4. Internet connectivity with connected experiences
enabled.
SWIPE
I help you STAND OUT from the
crowd with skills that will
TRANSFORM your CAREER
Get your skills up to speed with my courses
Follow me for tips and tutorials
Mynda Treacy | Microsoft MVP