![](https://livestylewebsitestorage.blob.core.windows.net/livestylewebsitescontainer/2021/06/office-scripts-in-excel-on-the-web-and-automation11.png)
去年の1月頃にパブリックプレビューとしてリリースされた Office Script が、ついに一般リリースされました。
Office Script は Google Spread Sheet と同じように JavaScript ベースで記録/記述できる自動化の機能です。Web版で自動化できることにより Google App Script と同様の処理ができるようになり、Webブラウザで完結できる作業が増えました。
Office Script でできることは?
まず、これまでのマクロ機能と同じように操作を記録することができます。
![](https://livestylewebsitestorage.blob.core.windows.net/livestylewebsitescontainer/2021/06/office-scripts-in-excel-on-the-web-and-automation1.png)
記録した処理はコードエディターで修正できます。
もちろん直接コードを書くことも可能です。言語は TypeScript で、JavaScript と同じ構文を使用することができます。JavaScript を利用したことがあれば抵抗なく記述いただけると思います。
![](https://livestylewebsitestorage.blob.core.windows.net/livestylewebsitescontainer/2021/06/office-scripts-in-excel-on-the-web-and-automation2.png)
Web版 Office Scriptsをつかってみよう
今回は Web版 Office Scripts の動作を簡単に確認するために、本機能をつかって同じ設定のシートを作成してみようと思います。
1. Excel on the web で新しい Book を作成して、自動化タブの「操作を記録」を選択します。
![](https://livestylewebsitestorage.blob.core.windows.net/livestylewebsitescontainer/2021/06/office-scripts-in-excel-on-the-web-and-automation3.png)
2. テーブルを作成するステップを記録します。
![](https://livestylewebsitestorage.blob.core.windows.net/livestylewebsitescontainer/2021/06/office-scripts-in-excel-on-the-web-and-automation4.png)
3. ステップが記録されると下記のようなコードが生成され、自動保存されます。TypeScript に慣れていない方でも、なんとなく処理している内容がわかりますね。
![](https://livestylewebsitestorage.blob.core.windows.net/livestylewebsitescontainer/2021/06/office-scripts-in-excel-on-the-web-and-automation5.png)
4. 新しい Book を開き、自動化タブから先程記録したスクリプトを選択します。
![](https://livestylewebsitestorage.blob.core.windows.net/livestylewebsitescontainer/2021/06/office-scripts-in-excel-on-the-web-and-automation6.png)
5. コードエディターが表示されるので、「実行」を選択します。
![](https://livestylewebsitestorage.blob.core.windows.net/livestylewebsitescontainer/2021/06/office-scripts-in-excel-on-the-web-and-automation7.png)
6. 先程の Book と同じテーブルが一瞬で自動作成されます。
![](https://livestylewebsitestorage.blob.core.windows.net/livestylewebsitescontainer/2021/06/office-scripts-in-excel-on-the-web-and-automation9.png)
今回は単純に同じ設定をシートへ適用するという処理だけ実施しましたが、Web版 Excel でこのような自動化処理が実現できるようになったことで、デバイスを選ばずより効率的な作業が可能になったのではないかと思います。
フローと連携
Web版の Office Scripts は単なる処理だけにとどまらず、Power Automate のフローと連携することも可能です。さらなる自動化が望めますね。
![](https://livestylewebsitestorage.blob.core.windows.net/livestylewebsitescontainer/2021/06/office-scripts-in-excel-on-the-web-and-automation10.png)
利用要件
- Excel on the web
(デスクトップなどのその他のプラットフォームは、サポートされていません) - OneDrive for Business
- Microsoft 365 Office デスクトップ アプリにアクセスできる、次のような商用または教育機関向けの Microsoft 365 ライセンス
- Microsoft 365 Business Standard
- Microsoft 365 Business Premium
- Microsoft 365 Apps for business
- Microsoft 365 Apps for enterprise
- Office 365 Enterprise E3
- Office 365 Enterprise E5
- Office 365 A3
- Office 365 A5
Web版Office ScriptsについてはMicrosoftの公式ドキュメントに詳しいチュートリアルがありますので是非お試しください。