From the course: Office Scripts In Excel: Automating Tasks

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Debugging Office Scripts with console.log()

Debugging Office Scripts with console.log() - Microsoft Excel Tutorial

From the course: Office Scripts In Excel: Automating Tasks

Debugging Office Scripts with console.log()

As you dive into developing your own solutions with Office Scripts, it's important to remember that not everything is going to work perfectly on the first try. In this video, I'll highlight console.log(), a particularly helpful tool for troubleshooting code in Office Scripts. To follow along, you'll want to open a new workbook and start by navigating to Automate and then New Script. Let's begin by wiping everything from Line 7 onwards and adding a new line with console.log(). We'll start by printing "Currently active sheet:" followed by selected sheet.getName. Let's run this script.console.log() is Office Script's way of printing messages to the console during script execution. It allows us to see the values of variables and results without altering the worksheet itself. We can see the output at the bottom of our code editor. At first, if we run the script, it might seem underwhelming. We already know this is Sheet 1, however, console.log() proves invaluable when operating through…

Contents