<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ソフトウェア | gungiiのなるほどHack&amp;Tips</title>
	<atom:link href="https://gungii.com/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>https://gungii.com</link>
	<description>「なるほど」と納得できる経験(実例)と知識(手順)を提供します。</description>
	<lastBuildDate>Wed, 24 Jul 2024 23:18:39 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://gungii.com/wp/wp-content/uploads/2022/02/cropped-favicon-32x32.png</url>
	<title>ソフトウェア | gungiiのなるほどHack&amp;Tips</title>
	<link>https://gungii.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【簡単!無料!】背景透過ツール「remove.bg」の使い方</title>
		<link>https://gungii.com/removebg-info/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Fri, 02 Feb 2024 06:50:45 +0000</pubDate>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[ソフトウェア]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=24101</guid>

					<description><![CDATA[画像に映り込んだ人やモノ以外の背景を切り抜いて透明にするのは、一般的にPhotoshop等の高機能な画像編集ソフトを使用して加工するのがほとんどです。しかしPhotoshop等のフォトレタッチソフトは、高額で操作が難しく [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>画像に映り込んだ人やモノ以外の背景を切り抜いて透明にするのは、一般的にPhotoshop等の高機能な画像編集ソフトを使用して加工するのがほとんどです。しかしPhotoshop等のフォトレタッチソフトは、高額で操作が難しく初心者の方は使い方を覚えるだけで一苦労です。ここでは、画像をアップロードするだけで簡単に背景だけを抜き取る事ができる「remove.bg」というツールをご紹介します。「remove.bg」は、ブラウザ上で利用できるため、インストールも必要なく、スマートフォンやタブレットでも利用することができますし、会員登録も不要なので、手軽に画像を切り抜きたい方に最適です。</p>



<div class="wp-block-cocoon-blocks-timeline timeline-box cf block-box cocoon-block-timeline"><div class="timeline-title">背景画像を切り抜いて透明化する手順</div><ul class="timeline">
<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">手順1</div><div class="timeline-item-content cf"><div class="timeline-item-title">背景を切り抜きたい画像を用意する。</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">手順2</div><div class="timeline-item-content cf"><div class="timeline-item-title">remove.bgにアクセスする</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">手順3</div><div class="timeline-item-content cf"><div class="timeline-item-title">画像をアップロードする</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">手順4</div><div class="timeline-item-content cf"><div class="timeline-item-title">切り抜かれた画像をダウンロードする</div><div class="timeline-item-snippet"></div></div></li>
</ul></div>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">背景画像の透過</a><ol><li><a href="#toc2" tabindex="0">背景を切り抜きたい画像を用意する。</a></li><li><a href="#toc3" tabindex="0">Remove.bgにアクセスする(https://www.remove.bg/ja)</a></li><li><a href="#toc4" tabindex="0">画像をアップロードする</a></li><li><a href="#toc5" tabindex="0">切り抜かれた画像をダウンロードする</a></li></ol></li><li><a href="#toc6" tabindex="0">背景画像の編集</a><ol><li><a href="#toc7" tabindex="0">背景の追加</a></li><li><a href="#toc8" tabindex="0">消去/復元</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">背景画像の透過</span></h2>



<h3 class="wp-block-heading"><span id="toc2">背景を切り抜きたい画像を用意する。</span></h3>



<p>アップロードする画像は、切り抜きの対象がはっきりとわかるものにしましょう。対象と背景の境界線が曖昧なものや、対象が複数あるものは避けた方が良いでしょう。<br>今回は以下の画像(無料の素材)を使って解説します。</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="672" height="448" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg01.png" alt="背景を透過させたい画像" class="wp-image-24103" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg01.png 672w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg01-300x200.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg01-500x333.png 500w" sizes="(max-width: 672px) 100vw, 672px" /></figure>



<h3 class="wp-block-heading"><span id="toc3">Remove.bgにアクセスする(https://www.remove.bg/ja)</span></h3>



<p>画面が表示されますので、「画像アップロード」をクリックします。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="658" height="390" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg02.png" alt="remove.bgのサイト" class="wp-image-24104" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg02.png 658w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg02-300x178.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg02-500x296.png 500w" sizes="(max-width: 658px) 100vw, 658px" /></figure>



<h3 class="wp-block-heading"><span id="toc4">画像をアップロードする</span></h3>



<p>パソコンから背景を消したい画像を選択してクリックします。すると読み込みが開始され、背景画像が透過された画像ができあがります。<br>留意:<br>無料で使えるのは低画質バージョンとなります。元は1920×1280だった画像が612×408と小さくなっていますので、ご注意下さい。そこまで高解像度を必要としないプロフィール写真や、ブログのアイキャッチ画像などを作る時は重宝します。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="638" height="266" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg03.png" alt="画像の選択" class="wp-image-24105" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg03.png 638w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg03-300x125.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg03-500x208.png 500w" sizes="(max-width: 638px) 100vw, 638px" /></figure>



<p>背景が透過された画像が出来上がります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="650" height="379" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg04.png" alt="完成した透過画像" class="wp-image-24106" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg04.png 650w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg04-300x175.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg04-500x292.png 500w" sizes="(max-width: 650px) 100vw, 650px" /></figure>



<p>長押しで、元画像と比較できます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="645" height="236" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg05.png" alt="元画像との比較" class="wp-image-24107" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg05.png 645w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg05-300x110.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg05-500x183.png 500w" sizes="(max-width: 645px) 100vw, 645px" /></figure>



<p>あとは、ダウンロードするだけです。<br>注意:<br>HD画像でダウンロードする場合は、「クレジット」(有料)というものが必要となります。</p>



<h3 class="wp-block-heading"><span id="toc5">切り抜かれた画像をダウンロードする</span></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="649" height="902" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg06.png" alt="画像のダウンロード" class="wp-image-24108" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg06.png 649w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg06-300x417.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg06-500x695.png 500w" sizes="(max-width: 649px) 100vw, 649px" /></figure>



<h2 class="wp-block-heading"><span id="toc6">背景画像の編集</span></h2>



<h3 class="wp-block-heading"><span id="toc7">背景の追加</span></h3>



<p>「背景を追加」をクリックすると、「写真」、「色」、「ぼかす」というファンクションが表示され、自分の好みの背景画像をアップロードすることができます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="631" height="363" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg11.png" alt="背景画像の追加" class="wp-image-24109" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg11.png 631w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg11-300x173.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg11-500x288.png 500w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg11-120x68.png 120w" sizes="(max-width: 631px) 100vw, 631px" /></figure>



<p>背景画像を選択してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="546" height="269" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg12.png" alt="背景画像の選択1" class="wp-image-24110" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg12.png 546w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg12-300x148.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg12-500x246.png 500w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p>別の背景画像を選択してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="547" height="270" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg13.png" alt="背景画像の選択2" class="wp-image-24111" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg13.png 547w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg13-300x148.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg13-500x247.png 500w" sizes="(max-width: 547px) 100vw, 547px" /></figure>



<h3 class="wp-block-heading"><span id="toc8">消去/復元</span></h3>



<p>「消去/復元」では、背景の透過を追加したり、元に戻したりできます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="556" height="308" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg14.png" alt="背景画像の消去/復元" class="wp-image-24112" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg14.png 556w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg14-300x166.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg14-500x277.png 500w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg14-160x90.png 160w" sizes="(max-width: 556px) 100vw, 556px" /></figure>



<h4 class="wp-block-heading">削除</h4>



<p>ノートパソコンを消してみます。「削除」を選択するとブラシが表示されますので、ブラシを使って消したい箇所を塗りつぶします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="565" height="596" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg15.png" alt="背景画像の消去" class="wp-image-24113" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg15.png 565w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg15-300x316.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg15-500x527.png 500w" sizes="(max-width: 565px) 100vw, 565px" /></figure>



<h4 class="wp-block-heading">復元</h4>



<p>復元を押すと、画像が復元されます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="565" height="282" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg16.png" alt="背景画像の復元" class="wp-image-24114" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg16.png 565w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg16-300x150.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg16-500x250.png 500w" sizes="(max-width: 565px) 100vw, 565px" /></figure>



<p>ブラシで復元範囲を塗ると、元画像が復元します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="566" height="281" src="https://gungii.com/wp/wp-content/uploads/2024/02/removebg17.png" alt="復元した元画像" class="wp-image-24115" srcset="https://gungii.com/wp/wp-content/uploads/2024/02/removebg17.png 566w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg17-300x149.png 300w, https://gungii.com/wp/wp-content/uploads/2024/02/removebg17-500x248.png 500w" sizes="(max-width: 566px) 100vw, 566px" /></figure>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>【完全解説】GASでWebアプリを作る方法(ログイン画面)</title>
		<link>https://gungii.com/gas06-info/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Sat, 05 Aug 2023 08:40:02 +0000</pubDate>
				<category><![CDATA[GAS]]></category>
		<category><![CDATA[ソフトウェア]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=23077</guid>

					<description><![CDATA[今回は、GAS (Google Apps Script) を使って、認証機能を付けた簡単なログイン画面を作ってみます。ログイン画面(login.html)から入力したemailアドレスとパスワードが、スプレッドシートの「 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>今回は、GAS (Google Apps Script) を使って、認証機能を付けた簡単なログイン画面を作ってみます。ログイン画面(login.html)から入力したemailアドレスとパスワードが、スプレッドシートの「社員ログイン情報」ファイルに記載されたemail(ログインID)とパスワードに一致すれば、「こんにちは!」(index.html)を表示して、不一致であれば「アクセス権がありません。」(error.html)と表示して、ログイン画面に戻ります。<br>注意:<br>ログイン画面のレイアウトはCSSは使用せず、bootstrapで作成しています。ここでは、Bootstrapの使い方については説明していませんので、必要な場合はネット等で検索して下さい。</p>



<p>「社員ログイン情報」ファイルのスプレッドシートの作り方は、以下のブログを参照下さい。</p>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-none">

<a href="https://gungii.com/spr01-info/" title="【完全解説】Googleスプレッドシートの使い方(交通費精算書の作成)" class="blogcard-wrap internal-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://gungii.com/wp/wp-content/uploads/2023/05/spr0100-ec-160x90.png" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://gungii.com/wp/wp-content/uploads/2023/05/spr0100-ec-160x90.png 160w, https://gungii.com/wp/wp-content/uploads/2023/05/spr0100-ec-300x169.png 300w, https://gungii.com/wp/wp-content/uploads/2023/05/spr0100-ec-500x281.png 500w, https://gungii.com/wp/wp-content/uploads/2023/05/spr0100-ec-768x432.png 768w, https://gungii.com/wp/wp-content/uploads/2023/05/spr0100-ec-800x450.png 800w, https://gungii.com/wp/wp-content/uploads/2023/05/spr0100-ec-120x68.png 120w, https://gungii.com/wp/wp-content/uploads/2023/05/spr0100-ec-320x180.png 320w, https://gungii.com/wp/wp-content/uploads/2023/05/spr0100-ec.png 1200w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【完全解説】Googleスプレッドシートの使い方(交通費精算書の作成)</div><div class="blogcard-snippet internal-blogcard-snippet">Googleスプレッドシートとは、Google社が無料で提供している「表計算ソフト」です。本記事では、Googleスプレッドシートの主な特徴、機能、基本的な使い方などを実務で運用しているフォームを作成しながらご紹介します。使い方を知るには実務で使ってみるのが一番です。ぜひご参考にしてみてください。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://gungii.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">gungii.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2024.06.08</div></div></div></div></a>
</div>



<p>GAS(Google Apps Script)については、以下のブログを参照下さい。</p>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-none">

<a href="https://gungii.com/gas01-info/" title="GoogleAppsScriptの始め方(基本的な使い方)" class="blogcard-wrap internal-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas01-ec-160x90.png" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas01-ec-160x90.png 160w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01-ec-500x282.png 500w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01-ec-300x169.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01-ec-768x432.png 768w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01-ec-800x450.png 800w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01-ec-120x68.png 120w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01-ec-320x180.png 320w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01-ec.png 1000w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">GoogleAppsScriptの始め方(基本的な使い方)</div><div class="blogcard-snippet internal-blogcard-snippet">本記事では、「GASを覚えたいけど、どこから始めたら良いのかわからない」方を対象に、GASを利用するに当たって理解しておくべきポイントや基本的なスプレッドシートの扱い方、スクリプト(プログラム)作成方法をでできるだけ、詳細に紹介しています。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://gungii.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">gungii.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2024.06.08</div></div></div></div></a>
</div>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-4" checked><label class="toc-title" for="toc-checkbox-4">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">gas ログイン認証の仕様</a><ol><li><a href="#toc2" tabindex="0">ログイン画面</a></li><li><a href="#toc3" tabindex="0">スクリプトの作成に必要なもの</a></li></ol></li><li><a href="#toc4" tabindex="0">gas ログイン認証のスクリプトの作成</a><ol><li><a href="#toc5" tabindex="0">doGet関数の実装</a></li><li><a href="#toc6" tabindex="0">doPost関数の実装</a></li><li><a href="#toc7" tabindex="0">ninsyou関数の実装</a></li></ol></li><li><a href="#toc8" tabindex="0">gas ログイン認証のHTMLの作成</a><ol><li><a href="#toc9" tabindex="0">login.htmlの作成</a></li><li><a href="#toc10" tabindex="0">index.htmlの作成</a></li><li><a href="#toc11" tabindex="0">error.htmlの作成</a></li></ol></li><li><a href="#toc12" tabindex="0">スクリプトレットの解説</a><ol><li><a href="#toc13" tabindex="0">スクリプトレットとは</a></li><li><a href="#toc14" tabindex="0">スクリプトレットの使い方</a></li><li><a href="#toc15" tabindex="0">実際の使い方</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">gas ログイン認証の仕様</span></h2>



<h3 class="wp-block-heading"><span id="toc2">ログイン画面</span></h3>



<p>アプリを起動してログイン画面から、emailアドレスとパスワードを入力します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="549" height="259" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0601.png" alt="ログイン画面(GAS)" class="wp-image-23079" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0601.png 549w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0601-300x142.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0601-500x236.png 500w" sizes="(max-width: 549px) 100vw, 549px" /></figure>



<h4 class="wp-block-heading">emailとパスワードが一致した場合</h4>



<p>入力されたemailアドレスとパスワードで、スプレッドシート:社員ログイン情報に記載されているemailアドレスとパスワードと比較して一致した場合は、以下の様に表示します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="591" height="173" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0602.png" alt="Wecome画面(GAS)" class="wp-image-23081" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0602.png 591w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0602-300x88.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0602-500x146.png 500w" sizes="(max-width: 591px) 100vw, 591px" /></figure>



<h4 class="wp-block-heading">emailとパスワードが不一致の場合</h4>



<p>emailアドレスとパスワードが一致しなかった場合は、以下のように表示して、「ログイン画面に戻る」をクリックすると、「ログイン画面」に戻ります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="588" height="131" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0603.png" alt="エラー画面(GAS)" class="wp-image-23082" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0603.png 588w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0603-300x67.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0603-500x111.png 500w" sizes="(max-width: 588px) 100vw, 588px" /></figure>



<h3 class="wp-block-heading"><span id="toc3">スクリプトの作成に必要なもの</span></h3>



<h4 class="wp-block-heading">スプレッドシート(社員ログイン情報)</h4>



<p>予め、以下のスプレッドシートを用意します。ログインの為のホワイトリストとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="638" height="201" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0604.png" alt="スプレッドシート(GAS)" class="wp-image-23083" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0604.png 638w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0604-300x95.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0604-500x158.png 500w" sizes="(max-width: 638px) 100vw, 638px" /></figure>



<h4 class="wp-block-heading">作成するGASスクリプトとHTML</h4>



<h5 class="wp-block-heading">コード.gs</h5>



<p>doGet関数、doPost関数、ninsyou関数を作成します。</p>



<h5 class="wp-block-heading">login.html</h5>



<p>emailアドレスとパスワードを入力するログイン画面を作成します。</p>



<h5 class="wp-block-heading">index.html</h5>



<p>emailとパスワードが一致した場合に表示する画面を作成します。</p>



<h5 class="wp-block-heading">error.html</h5>



<p>emailとパスワードが不一致の場合に表示する画面を作成します。</p>



<h2 class="wp-block-heading"><span id="toc4">gas ログイン認証のスクリプトの作成</span></h2>



<h3 class="wp-block-heading"><span id="toc5">doGet関数の実装</span></h3>



<p>まずはスプレッドシートを操作する為に、スプレッドシートのオブジェクトを取得します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="552" height="201" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0611.png" alt="doGet関数(GAS)" class="wp-image-23084" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0611.png 552w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0611-300x109.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0611-500x182.png 500w" sizes="(max-width: 552px) 100vw, 552px" /></figure>



<p>ここでは次の5つの処理を行います。</p>



<h4 class="wp-block-heading">htmlファイルを生成</h4>



<p>Webブラウザで表示するにはhtmlファイルが必要で、生成処理もdoGetで行います。</p>



<p><strong>const htmlOutput = HtmlService.createTemplateFromFile(&#8220;login&#8221;);</strong></p>



<p>htmlのファイル名は「login.html」とすることにします。この場合は文字列”login”を、HtmlServiceのcreateTemplateFromFileというメソッドに指定します。</p>



<h4 class="wp-block-heading">最新のデプロイURLの反映</h4>



<p>login.htmlのform actionにURLを貼り付けるとデプロイの度に、その時点でのデプロイURLに変化してしまいます。そこでこれを解決するために、デプロイURLを変数化してformタグに反映する必要があります。次の1行を追加します。</p>



<p><strong>htmlOutput.deployURL = ScriptApp.getService().getUrl();</strong></p>



<p>そして、login.htmlのactionは、以下のようにします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="559" height="292" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0612.png" alt="デプロイURLの反映(GAS)" class="wp-image-23085" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0612.png 559w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0612-300x157.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0612-500x261.png 500w" sizes="(max-width: 559px) 100vw, 559px" /></figure>



<h4 class="wp-block-heading">HtmlOutputオブジェクトへの変換</h4>



<p>HtmlServiceオブジェクトのメソッドであるcreateTemplateFromFileは、指定のhtmlファイルからHtmlTemplateオブジェクトを生成するメソッドです。そこでhtmlOutput.evaluate()で、HtmlTemplateオブジェクトをevaluate(評価)することでHtmlOutputという形式のオブジェクトに変換しています。変換されたHtmlOutputオブジェクトはブラウザで表示ができる状態となります。<br>留意:<br>evaluate()とはHtmlTemplateオブジェクトをHtmlOutputオブジェクトに変換するメソッドです。HtmlOutputオブジェクトに変換することでWebページを表示できるようになります。</p>



<h4 class="wp-block-heading">タイトルの設定</h4>



<p>通常ブラウザで開いたWebページのタブには、そのページのアイコン(ファビコン)と、タイトルが表示されますが、GASで作ったページの場合は、Apps ScriptのアイコンとURLがそのまま表示されます。そこでhtmlOutput.setTitle(&#8220;ログイン画面&#8221;)でタイトルを設定します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="627" height="502" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0613.png" alt="Webページのタブ(GAS)" class="wp-image-23086" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0613.png 627w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0613-300x240.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0613-500x400.png 500w" sizes="(max-width: 627px) 100vw, 627px" /></figure>



<h4 class="wp-block-heading">スマホ対応</h4>



<p>Webページをスマホ対応する為に、headタグ内にviewportの設定をmetaタグで指定します。</p>



<p><strong><span class="bold-red">HtmlOutputオブジェクト.addMetaTag(name属性の値, content属性の値)</span></strong></p>



<p><strong>htmlOutput.addMetaTag(&#8216;viewport&#8217;, &#8216;width=device-width, initial-scale=1&#8217;);</strong></p>



<p>width=device-width：表示領域の幅を端末画面の幅に合わせる<br>initial-scale=1：初期のズームの倍率を1、つまり拡縮なしに設定しておく</p>



<h3 class="wp-block-heading"><span id="toc6">doPost関数の実装</span></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="637" height="411" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0614.png" alt="doPost関数(GAS)" class="wp-image-23087" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0614.png 637w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0614-300x194.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0614-500x323.png 500w" sizes="(max-width: 637px) 100vw, 637px" /></figure>



<h4 class="wp-block-heading">入力されたemailアドレスと、パスワードの取得</h4>



<p><strong>const email = e.parameters.email.toString();</strong><br><strong>const password = e.parameters.password.toString();</strong></p>



<p>doGetはデプロイしたURLにアクセスしたときに(GETリクエストした時に)実行され、doPostはフォームの送信ボタンが押されたときに(POSTリクエストした時に)実行されます。</p>



<h4 class="wp-block-heading">ninsyou関数の呼び出しと、チェック結果の取得</h4>



<p><strong>const check = ninsyou(email,password);</strong></p>



<p>ninsyou関数を呼び出し、チェック結果を変数checkに格納します。</p>



<h4 class="wp-block-heading">チェック結果による画面の切り替え</h4>



<p>formの送信ボタンが押下されて、チェック結果によりindex.htmlかerror.htmlを表示します。</p>



<p><strong>if ( check === true ) {</strong><br>　emailをindex.html(スクリプトレット)へ送り、最初の画面(index.html)を表示します。<br><strong>} else {</strong><br>　エラー画面(error.html)を表示します。<br><strong>}</strong></p>



<h3 class="wp-block-heading"><span id="toc7">ninsyou関数の実装</span></h3>



<p>doPost関数から呼び出されるninsyou関数を実装します。<br>スプレッドシート:社員ログイン情報と、emailとパスワードが一致するかをチェックして、一致していれば、trueを返し、不一致であればfalseを返します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="623" height="391" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0615.png" alt="ninsyou関数(GAS)" class="wp-image-23088" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0615.png 623w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0615-300x188.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0615-500x314.png 500w" sizes="(max-width: 623px) 100vw, 623px" /></figure>



<h4 class="wp-block-heading">「社員ログイン情報」のシートの取得</h4>



<p>スプレッドシートの「社員ログイン情報」ファイルの該当シート(シート1)を取得します。</p>



<p><strong>const sheets = SpreadsheetApp.openByID(&#8220;ID&#8221;);</strong><br><strong>const sheet = sheets.getSheetByName(&#8220;シート1&#8221;);</strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="635" height="201" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0616.png" alt="社員ログイン情報の取得(GAS)" class="wp-image-23089" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0616.png 635w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0616-300x95.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0616-500x158.png 500w" sizes="(max-width: 635px) 100vw, 635px" /></figure>



<h4 class="wp-block-heading">シート内のセルの取得</h4>



<p>取得する範囲の開始セルを指定して、そこから何行分、何列分取り出すかを指定します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="457" height="49" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0617.png" alt="getRangeメソッド(GAS)" class="wp-image-23090" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0617.png 457w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0617-300x32.png 300w" sizes="(max-width: 457px) 100vw, 457px" /></figure>



<p><strong>const ninsyou_email = sheet.getRange(2,3,3,1).getValues();</strong><br><strong>const ninsyou_pass = sheet.getRange(2,4,3,1).getValues();</strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="635" height="201" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0618.png" alt="シート内のセルの取得(GAS)" class="wp-image-23091" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0618.png 635w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0618-300x95.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0618-500x158.png 500w" sizes="(max-width: 635px) 100vw, 635px" /></figure>



<p>例えば、emailの場合は、開始セルが2行目の3列で、そこから3行分、1列分を取り出しています。つまり、info@gungii.com、hello@kaithuburi.net、info@gungii.siteの3つのemailアドレスを取得しています。</p>



<p>[ 最終行を自動で判別して取得する。]<br>最終行を自動で取得して、次のように書き換えることもできます。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="346" height="49" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0619.png" alt="getLastRowメソッド(GAS)" class="wp-image-23092" style="width:346px;height:49px" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0619.png 346w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0619-300x42.png 300w" sizes="(max-width: 346px) 100vw, 346px" /></figure>



<p><strong>const ninsyou_email = sheet.getRange(2,3,sheet.getLastRow(),1).getValues();</strong><br><strong>const ninsyou_pass = sheet.getRange(2,4,sheet.getLastRow(),1).getValues();</strong></p>



<h4 class="wp-block-heading">email、パスワードのチェック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="621" height="269" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0620.png" alt="forinループ(GAS)" class="wp-image-23093" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0620.png 621w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0620-300x130.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0620-500x217.png 500w" sizes="(max-width: 621px) 100vw, 621px" /></figure>



<p>ninsyou_emailの要素数(ここでは3つ)だけ繰り返します。つまり、emailアドレスが3つありますので3回繰り返し、変数iを0、1、2と更新します。for inではiのところに配列のindexが返ってきます。例えば、入力されたemailアドレスがinfo@gungii.siteで、パスワードがpas54321の場合、変数iが2の時に、ninsyou_email[2]とemail(入力されたemailアドレス)且つ、ninsyou_pass[2]とpassword(入力されたパスワード) が一致しますので、hanteiにtrueを代入してreturnで戻ります。<br>留意:<br>for in文はオブジェクト(連想配列)のデータからキー要素を順不同で取得して、繰り返し処理を実行します。定義された順番にオブジェクトのキーが取り出されるかは保証されていませんので、配列のデータ処理には適していません。このケースの場合配列は関係なくtrueかfalseかのみですので、問題ありませんが配列が必要な場合は、for ofを使うことが必要です。<br>ninsyou_email = sheet.getRange(2,3,3,1).getValues();には、次のような二次元配列となっています。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="508" height="96" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0621.png" alt="配列のログ(GAS)" class="wp-image-23094" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0621.png 508w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0621-300x57.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0621-500x94.png 500w" sizes="(max-width: 508px) 100vw, 508px" /></figure>



<h2 class="wp-block-heading"><span id="toc8">gas ログイン認証のHTMLの作成</span></h2>



<h3 class="wp-block-heading"><span id="toc9">login.htmlの作成</span></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="627" height="408" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0631.png" alt="login.htmlへのCDN挿入(GAS)" class="wp-image-23095" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0631.png 627w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0631-300x195.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0631-500x325.png 500w" sizes="(max-width: 627px) 100vw, 627px" /></figure>



<h4 class="wp-block-heading">CSSとJavascripのCDNを挿入</h4>



<p>Bootstrapより、CSSとJavascripのCDN(コンテンツデリバリーネットワーク)を挿入します。CSSは、headの適当な場所に挿入してよいですが、Javascriptは、bodyの最後に挿入して下さい。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="444" height="297" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0632.png" alt="bootstrapのCDN(GAS)" class="wp-image-23096" style="width:444px;height:297px" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0632.png 444w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0632-300x201.png 300w" sizes="(max-width: 444px) 100vw, 444px" /></figure>



<h4 class="wp-block-heading">formの編集</h4>



<p>Bootstrapから最も近いformを選択して、htmlを編集しています。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="615" height="616" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0633.png" alt="formの編集(GAS)" class="wp-image-23097" style="width:617px;height:618px" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0633.png 615w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0633-300x300.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0633-500x501.png 500w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0633-150x150.png 150w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0633-100x100.png 100w" sizes="(max-width: 615px) 100vw, 615px" /></figure>



<h3 class="wp-block-heading"><span id="toc10">index.htmlの作成</span></h3>



<p>Bootstrapより、CSSとJavascripのCDN(コンテンツデリバリーネットワーク)を挿入します。CSSは、headの適当な場所に挿入してよいですが、Javascriptは、bodyの最後に挿入して下さい。<br>注意:login.htmlと同様、index.htmlにもCSSとJavascriptのCDNを挿入します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="629" height="461" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0634.png" alt="index.htmlへのCDN挿入(GAS)" class="wp-image-23098" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0634.png 629w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0634-300x220.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0634-500x366.png 500w" sizes="(max-width: 629px) 100vw, 629px" /></figure>



<h3 class="wp-block-heading"><span id="toc11">error.htmlの作成</span></h3>



<h4 class="wp-block-heading">CSSとJavascripのCDNを挿入</h4>



<p>Bootstrapより、CSSとJavascripのCDN(コンテンツデリバリーネットワーク)を挿入します。CSSは、headの適当な場所に挿入してよいですが、Javascriptは、bodyの最後に挿入して下さい。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="625" height="253" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0635.png" alt="error.htmlへのCDN挿入(GAS)" class="wp-image-23099" style="width:625px;height:253px" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0635.png 625w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0635-300x121.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0635-500x202.png 500w" sizes="(max-width: 625px) 100vw, 625px" /></figure>



<h4 class="wp-block-heading">「ログイン画面」に戻る</h4>



<p>「ログイン画面に戻る」をクリックすると、ログイン画面(初期画面)に戻るようにします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="591" height="351" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0637.png" alt="エラー画面(GAS)" class="wp-image-23100" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0637.png 591w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0637-300x178.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0637-500x297.png 500w" sizes="(max-width: 591px) 100vw, 591px" /></figure>



<h5 class="wp-block-heading">error.htmlの修正</h5>



<p>次の1行を追加します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="563" height="402" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0638.png" alt="error.htmlの修正(GAS)" class="wp-image-23101" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0638.png 563w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0638-300x214.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0638-500x357.png 500w" sizes="(max-width: 563px) 100vw, 563px" /></figure>



<h5 class="wp-block-heading">コード.gsの修正</h5>



<p>次の1行を追加します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="562" height="513" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0639.png" alt="コード.gsの修正(GAS)" class="wp-image-23102" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0639.png 562w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0639-300x274.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0639-500x456.png 500w" sizes="(max-width: 562px) 100vw, 562px" /></figure>



<p>index.htmlの方も追加していますが、次の画面(例えば、社員情報の表示や雇用契約書の表示etc)が決まっていませんので、現状は使っていません。</p>



<h2 class="wp-block-heading"><span id="toc12">スクリプトレットの解説</span></h2>



<h3 class="wp-block-heading"><span id="toc13">スクリプトレットとは</span></h3>



<p>GASでは「スクリプトレットタグ」を使うことで&#8221;gsコードからHTMLに変数を渡したり、&#8221;HTML内にgsコードを埋め込んだ&#8221;りすることができます。HTML内で、（スクリプトレットタグ）で囲まれた部分はgsコードとして実行することができます。GASにおけるスクリプトレットは３種類あり、やりたいことによって使い分けます。</p>



<p>スクリプトレットは、doPost関数内のevaluateメソッドによって実行されます。つまり、サーバーからHTTPレスポンスが送出される直前のタイミングで実行され、結果のHTML(今回の例ではoption要素)が送信されます。GASのスクリプトが実行されるのはあくまでサーバー側となります。</p>



<h3 class="wp-block-heading"><span id="toc14">スクリプトレットの使い方</span></h3>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="614" height="184" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0641.png" alt="スクリプトレットの使い方1(GAS)" class="wp-image-23103" style="width:614px;height:184px" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0641.png 614w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0641-300x90.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0641-500x150.png 500w" sizes="(max-width: 614px) 100vw, 614px" /></figure>



<p>上記の例では、doGet関数内でHtmlService.createTemplateFromFileメソッドを使用してHTMLファイルを読み込んでいます。このHTMLファイル内にスクリプトレットを使用することができます。template変数にyoukenプロパティを追加して、&#8221;GASを学ぼう&#8221;を代入しています。そしてreturn文でtemplate.evaluateメソッドを呼び出して、評価結果を返しています。この評価結果がクライアントに送信されるHTMLページとなります。</p>



<p><strong>function doGet() {</strong><br><strong>let template = HtmlService.createTemplateFromFile(&#8220;index&#8221;);</strong><br><strong>template.youken = &#8220;GASを学ぼう&#8221;;</strong><br><strong>return template.evaluate().setTitle(template.youken);</strong><br><strong>}</strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="614" height="192" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0642.png" alt="スクリプトレットの使い方2(GAS)" class="wp-image-23104" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0642.png 614w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0642-300x94.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0642-500x156.png 500w" sizes="(max-width: 614px) 100vw, 614px" /></figure>



<p>HTMLファイル内では、次のようにスクリプトレットを使用することができます。</p>



<p><strong>template.(HTML側で定義されている変数名) = (gsコード側で代入したい変数名)</strong></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="606" height="188" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0643.png" alt="スクリプトレットの使い方3(GAS)" class="wp-image-23105" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0643.png 606w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0643-300x93.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0643-500x155.png 500w" sizes="(max-width: 606px) 100vw, 606px" /></figure>



<h3 class="wp-block-heading"><span id="toc15">実際の使い方</span></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="617" height="201" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0644.png" alt="実際の使い方1(GAS)" class="wp-image-23106" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0644.png 617w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0644-300x98.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0644-500x163.png 500w" sizes="(max-width: 617px) 100vw, 617px" /></figure>



<p><strong>function doPost(e) {</strong><br>　　　　・<br><strong>template = HtmlService.createTemplateFromFile(&#8220;index&#8221;);</strong><br><strong>template.namae = email;</strong><br><strong>return template.evaluate();</strong><br>　　　　・<br><strong>}</strong></p>



<p>上記の例では、doPost関数内でHtmlService.createTemplateFromFileメソッドを使用してHTMLファイルを読み込んでいます。このHTMLファイル内にスクリプトレットを使用することができます。template変数にnamaeプロパティを追加して、emailを代入しています。そしてreturn文でtemplate.evaluateメソッドを呼び出して、評価結果を返しています。この評価結果がクライアントに送信されるHTMLページとなります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="622" height="233" src="https://gungii.com/wp/wp-content/uploads/2023/08/gas0645.png" alt="実際の使い方2(GAS)" class="wp-image-23107" srcset="https://gungii.com/wp/wp-content/uploads/2023/08/gas0645.png 622w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0645-300x112.png 300w, https://gungii.com/wp/wp-content/uploads/2023/08/gas0645-500x187.png 500w" sizes="(max-width: 622px) 100vw, 622px" /></figure>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>【完全解説】GASでWebアプリを作る方法(簡単なWebページ)</title>
		<link>https://gungii.com/gas05-info/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Thu, 13 Jul 2023 05:33:01 +0000</pubDate>
				<category><![CDATA[GAS]]></category>
		<category><![CDATA[ソフトウェア]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=23042</guid>

					<description><![CDATA[GoogleAppscript(GAS)はグーグルが提供するスクリプトサービスで、スプレッドシートを自動処理するプログラムが作成できます。さらにExcelのマクロのような事だけでなく、GASを使って作成したスクリプトを、 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>GoogleAppscript(GAS)はグーグルが提供するスクリプトサービスで、スプレッドシートを自動処理するプログラムが作成できます。さらにExcelのマクロのような事だけでなく、GASを使って作成したスクリプトを、Webブラウザ上で動作するWebアプリケーションとして公開することも可能です。GoogleAppsScriptの実行は、Googleのサーバ上で行いますから、通常のWeb開発のようにレンタルサーバを用意したり、Webサーバをたてたりする必要もありません。これからWebアプリの開発に取り組みたい方は、開発環境としてGASを使ってみるのも一つの方法となります。ここでは、GASを使って簡単なWebページを公開しながら、GASウェブアプリケーションのデプロイと公開方法について解説します。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-orange-border-color cocoon-block-tab-caption-box"><div class="tab-caption-box-label block-box-label box-label fab-check"><span class="tab-caption-box-label-text block-box-label-text box-label-text">web公開の流れ</span></div><div class="tab-caption-box-content block-box-content box-content">
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="681" height="240" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0501.png" alt="Webアプリの流れ(GAS)" class="wp-image-23044" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0501.png 681w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0501-300x106.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0501-500x176.png 500w" sizes="(max-width: 681px) 100vw, 681px" /></figure>



<ol class="wp-block-list">
<li>ユーザーがGASアプリのURLをクリックすると、ブラウザがこれを解析してGoogleクラウドサーバーに「HTMLを下さい」というGETリクエストを送信します。</li>



<li>GASはブラウザからのリクエストを受け取るとルール(シンプルトリガー)に従い「doGet関数」を実行します。Spreadsheetから必要なデータを読み込む等、送り返すWebページを作るための準備をします。</li>



<li>doGet()の最後にHTML文書をreturnすることで、それがブラウザへのレスポンスとして送られます。(HtmlOutputオブジェクトをdoGet関数でreturnする)</li>



<li>ブラウザは、レスポンスとして受け取ったHTMLを解析(レンダリング)します。</li>



<li>ユーザーは、Webページが表示されたことを確認します。</li>
</ol>



<p>[ getメソッドとpostメソッド ]</p>



<p>Webアプリでは、クライアント側がHTTPリクエストを送り、サーバー側がHTTPレスポンスを返すという流れで通信します。HTTPリクエストには主なものとしてGETメソッドとPOSTメソッドがあります。GETメソッドは、指定したURLのページをリクエストする際にURLのあとにデータを付加して送信します。例えばGoogle等で検索すると、URLに検索語句などのデータが含まれています。これは検索キーワードをGETメソッドで送っているためです。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="606" height="44" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0502.png" alt="Google検索(doGet関数)" class="wp-image-23045" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0502.png 606w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0502-300x22.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0502-500x36.png 500w" sizes="(max-width: 606px) 100vw, 606px" /></figure>



<p>POSTメソッドは、投稿専用のHTTPリクエストでGETメソッドに比べて大容量のデータを送信できます。そしてデータ送信にURLを使わないので閲覧履歴などから送信内容を見られることはありません。用途としてデータを取得する場合にはGET、送る場合にはPOSTといった感じで使い分けをすると良いでしょう。</p>



<p>[ GASのdoGet関数とdoPost関数 ]</p>



<p>GASでは、GETメソッドに対応するdoGet関数、POSTメソッドに対応するdoPost関数を定義し、応答データはHtmlOutputオブジェクトを戻り値にします。この戻り値がHTTPレスポンスとして、サーバーからクライアントへ送出されます。doGet関数もdoPost関数もシンプルトリガーの1種でGASのWebアプリのURLにブラウザからアクセスがあった時に実行されます。</p>
</div></div>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-6" checked><label class="toc-title" for="toc-checkbox-6">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">GASでWebアプリを公開する方法</a><ol><li><a href="#toc2" tabindex="0">スクリプトエディターを開く</a></li><li><a href="#toc3" tabindex="0">引数に書いたHTMLコードを公開</a></li><li><a href="#toc4" tabindex="0">HTMLファイル(静的)を公開</a></li><li><a href="#toc5" tabindex="0">HTMLファイル(動的)を公開</a></li></ol></li><li><a href="#toc6" tabindex="0">ページタイトル、ファビコンの変更方法</a><ol><li><a href="#toc7" tabindex="0">ページタイトルを変更する。</a></li><li><a href="#toc8" tabindex="0">ファビコンを変更する。</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">GASでWebアプリを公開する方法</span></h2>



<p>それでは、簡単なWebアプリケーションを作成、実行してみます。まず、スクリプトエディターを開きます。</p>



<h3 class="wp-block-heading"><span id="toc2">スクリプトエディターを開く</span></h3>



<h4 class="wp-block-heading">スプレッドシートの作成</h4>



<p>まずは新規のスプレッドシートを作成します</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="563" height="265" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0511.png" alt="スプレッドシートの作成(gas)" class="wp-image-23046" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0511.png 563w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0511-300x141.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0511-500x235.png 500w" sizes="(max-width: 563px) 100vw, 563px" /></figure>



<h4 class="wp-block-heading">ファイル名の変更</h4>



<p>ここでは「GASで簡単なWebページを表示する」としています。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="620" height="428" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0512.png" alt="ファイル名の変更(GAS)" class="wp-image-23047" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0512.png 620w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0512-300x207.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0512-500x345.png 500w" sizes="(max-width: 620px) 100vw, 620px" /></figure>



<h4 class="wp-block-heading">AppsScriptの選択</h4>



<p>次に「拡張機能」から「Apps Script」を開きます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="518" height="465" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0513.png" alt="AppsScriptの選択(GAS)" class="wp-image-23048" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0513.png 518w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0513-300x269.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0513-500x449.png 500w" sizes="(max-width: 518px) 100vw, 518px" /></figure>



<h4 class="wp-block-heading">プロジェクト名の変更</h4>



<p>ここでは「Webページの表示」としています。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="555" height="364" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0514.png" alt="プロジェクト名の変更(GAS)" class="wp-image-23049" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0514.png 555w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0514-300x197.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0514-500x328.png 500w" sizes="(max-width: 555px) 100vw, 555px" /></figure>



<h3 class="wp-block-heading"><span id="toc3">引数に書いたHTMLコードを公開</span></h3>



<p>createHtmlOutputメソッドの引数にHTMLを書いて、Webページを表示してみます。</p>



<h4 class="wp-block-heading">doGet関数を定義</h4>



<p>デフォルトで定義されているmyFunction関数は削除して、doGet関数を定義します。doGet関数はHtmlOutputオブジェクトを返す必要があります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="569" height="360" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0521.png" alt="doGet関数(GAS)" class="wp-image-23050" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0521.png 569w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0521-300x190.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0521-500x316.png 500w" sizes="(max-width: 569px) 100vw, 569px" /></figure>



<h4 class="wp-block-heading">スクリプトの作成</h4>



<p>HtmlサービスのcreateHtmlOutputメソッドは、引数に指定したHTMLコードから生成したHtmlOutputオブジェクトを返します(ソースコードをHTML出力用に変換する関数です。)<br>HtmlOutputオブジェクトはHTMLのデータを保持するもので、セキュリティの問題が起きない様にサニタイズする働きも持ちます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="575" height="225" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0522.png" alt="createHtmlOutput(GAS)" class="wp-image-23051" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0522.png 575w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0522-300x117.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0522-500x196.png 500w" sizes="(max-width: 575px) 100vw, 575px" /></figure>



<pre class="wp-block-code"><code>function doGet() {
  return HtmlService.createHtmlOutput("&lt;h1&gt;Hello! GAS!&lt;/h1&gt;");
}</code></pre>



<h4 class="wp-block-heading">公開</h4>



<p>右上の「デプロイ」から「新しいデプロイ」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="569" height="175" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0523.png" alt="公開手順1(新しいデプロイ)" class="wp-image-23052" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0523.png 569w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0523-300x92.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0523-500x154.png 500w" sizes="(max-width: 569px) 100vw, 569px" /></figure>



<h5 class="wp-block-heading">「ウェブアプリ」の選択</h5>



<p>「種類の選択」の歯車アイコンをクリックし、「ウェブアプリ」をクリックします。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="506" height="277" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0524.png" alt="公開手順2(ウェブアプリの選択)" class="wp-image-23053" style="width:506px;height:277px" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0524.png 506w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0524-300x164.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0524-500x274.png 500w" sizes="(max-width: 506px) 100vw, 506px" /></figure>



<h5 class="wp-block-heading">設定</h5>



<p>以下を設定して、右下の「デプロイ」をクリックします。</p>



<ul class="wp-block-list">
<li>「新しい説明文」にわかりやすい説明文を入力します。<br>ここでは「最初のデプロイ」と入力します。</li>



<li>「次のユーザーとして実行」で「自分（xxxxx@gmail.com）」を選択します。</li>



<li>「アクセスできるユーザー」で「Googleアカウントを持つ全員」を選択</li>
</ul>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="502" height="399" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0525.png" alt="公開手順3(デプロイの設定)" class="wp-image-23054" style="width:501px;height:398px" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0525.png 502w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0525-300x238.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0525-500x397.png 500w" sizes="(max-width: 502px) 100vw, 502px" /></figure>



<h5 class="wp-block-heading">デプロイの完了</h5>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="504" height="398" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0526.png" alt="公開手順4(デプロイの完了)" class="wp-image-23055" style="width:504px;height:398px" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0526.png 504w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0526-300x237.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0526-500x395.png 500w" sizes="(max-width: 504px) 100vw, 504px" /></figure>



<h5 class="wp-block-heading">公開</h5>



<p>ウェブアプリのURLをクリックしてWebページを表示してみましょう。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="529" height="213" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0527.png" alt="Webページの表示(GAS)" class="wp-image-23056" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0527.png 529w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0527-300x121.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0527-500x201.png 500w" sizes="(max-width: 529px) 100vw, 529px" /></figure>



<p>無事、HTMLファイルの内容が表示されていることが確認できました！</p>



<h3 class="wp-block-heading"><span id="toc4">HTMLファイル(静的)を公開</span></h3>



<p>先ほどは、createHtmlOutputメソッドの引数にHTMLを書きましたが、今度はHTMLファイルの内容を表示させてみます。createHtmlOutputFromFileメソッドで指定されたHTMLファイルを公開します。</p>



<h4 class="wp-block-heading">doGet関数を定義</h4>



<p>デフォルトで定義されているmyFunction関数は削除して、doGet関数を定義します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="569" height="360" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0521.png" alt="doGet関数(GAS)" class="wp-image-23050" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0521.png 569w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0521-300x190.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0521-500x316.png 500w" sizes="(max-width: 569px) 100vw, 569px" /></figure>



<h4 class="wp-block-heading">HTMLファイルの追加</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="568" height="181" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0532.png" alt="HTMLファイルの追加(GAS)" class="wp-image-23058" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0532.png 568w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0532-300x96.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0532-500x159.png 500w" sizes="(max-width: 568px) 100vw, 568px" /></figure>



<pre class="wp-block-code"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;base target="_top"&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;Hello! GAS!&lt;/h1&gt;
  &lt;/body&gt;
&lt;/html&gt;</code></pre>



<h4 class="wp-block-heading">スクリプトの作成</h4>



<p>HTMLファイルの内容を表示するには、createHtmlOutputFromFileメソッドを使います。こちらは、HTMLファイルからHtmlOutputオブジェクトを生成して返します。引数にHTMLファイル名を指定しますが、拡張子は不要です。<br>注意:<br>createTemplateFromFileの場合にはスクリプトレットが使用できますが、createOutputFromFileの場合には使用することができません。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="584" height="236" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0531.png" alt="createHtmlOutputFromFile(gas)" class="wp-image-23057" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0531.png 584w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0531-300x121.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0531-500x202.png 500w" sizes="(max-width: 584px) 100vw, 584px" /></figure>



<pre class="wp-block-code"><code>function doGet() {
  return HtmlService.createHtmlOutputFromFile("index");
}</code></pre>



<h4 class="wp-block-heading">公開</h4>



<p>右上の「デプロイ」から「新しいデプロイ」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="568" height="174" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0533.png" alt="公開手順1(新しいデプロイ)" class="wp-image-23059" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0533.png 568w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0533-300x92.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0533-500x153.png 500w" sizes="(max-width: 568px) 100vw, 568px" /></figure>



<h5 class="wp-block-heading">「ウェブアプリ」の選択</h5>



<p>「種類の選択」の歯車アイコンをクリックし、「ウェブアプリ」をクリックします。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="506" height="277" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0534.png" alt="公開手順2(ウェブアプリの選択)" class="wp-image-23060" style="width:506px;height:277px" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0534.png 506w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0534-300x164.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0534-500x274.png 500w" sizes="(max-width: 506px) 100vw, 506px" /></figure>



<p></p>



<h5 class="wp-block-heading">設定</h5>



<p>以下を設定して、右下の「デプロイ」をクリックします。</p>



<ul class="wp-block-list">
<li>「新しい説明文」にわかりやすい説明文を入力します。<br>ここでは「最初のデプロイ」と入力します。</li>



<li>「次のユーザーとして実行」で「自分（xxxxx@gmail.com）」を選択します。</li>



<li>「アクセスできるユーザー」で「Googleアカウントを持つ全員」を選択</li>
</ul>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="502" height="399" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0535.png" alt="公開手順3(デプロイの設定)" class="wp-image-23062" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0535.png 502w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0535-300x238.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0535-500x397.png 500w" sizes="(max-width: 502px) 100vw, 502px" /></figure>



<h5 class="wp-block-heading">デプロイの完了</h5>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="504" height="398" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0536.png" alt="公開手順4(デプロイの完了)" class="wp-image-23063" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0536.png 504w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0536-300x237.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0536-500x395.png 500w" sizes="(max-width: 504px) 100vw, 504px" /></figure>



<h5 class="wp-block-heading">公開</h5>



<p>ウェブアプリのURLをクリックしてWebページを表示してみましょう。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="569" height="184" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0537.png" alt="Webページの表示(GAS)" class="wp-image-23064" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0537.png 569w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0537-300x97.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0537-500x162.png 500w" sizes="(max-width: 569px) 100vw, 569px" /></figure>



<p>無事、HTMLファイルの内容が表示されていることが確認できました！</p>



<h3 class="wp-block-heading"><span id="toc5">HTMLファイル(動的)を公開</span></h3>



<p>こちらは、createHtmlOutputFromFileではなく、craeteTemplateFromFileメソッドを使います。</p>



<p>craeteTemplateFromFileは、指定のhtmlファイルからHtmlTemplateオブジェクトを生成するメソッドで、HtmlTemplateオブジェクトを使うことでスクリプトレットと呼ばれる動的にHTMLを生成する構文を使うことができます。<br>(スクリプトレット構文を使うとHTMLの中にGASのコードを埋め込むことができます。)</p>



<h4 class="wp-block-heading">doGet関数を定義</h4>



<p>デフォルトで定義されているmyFunction関数は削除して、doGet関数を定義します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="569" height="360" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0521.png" alt="doGet関数(GAS)" class="wp-image-23050" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0521.png 569w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0521-300x190.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0521-500x316.png 500w" sizes="(max-width: 569px) 100vw, 569px" /></figure>



<h4 class="wp-block-heading">HTMLファイルの追加</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="568" height="181" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0532.png" alt="HTMLファイルの追加(GAS)" class="wp-image-23058" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0532.png 568w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0532-300x96.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0532-500x159.png 500w" sizes="(max-width: 568px) 100vw, 568px" /></figure>



<h4 class="wp-block-heading">スクリプトの作成</h4>



<p>HTMLファイルの内容を表示するには、createTemplateFromFileメソッドを使います。<br>こちらの場合は、evaluate();を付ける必要があります。引数にHTMLファイル名を指定しますが、拡張子は不要です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="231" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0541.png" alt="createTemplateFromFile(GAS)" class="wp-image-23065" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0541.png 577w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0541-300x120.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0541-500x200.png 500w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<pre class="wp-block-code"><code>function doGet() {
  const template = HtmlService.createTemplateFromFile("index");
  const htmlOutput = template.evaluate();
  return htmlOutput;
}</code></pre>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box has-text-color has-border-color has-teal-color has-amber-border-color cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-edit"><span class="label-box-label-text block-box-label-text box-label-text">[ createHtmlOutputFromFileと、createTemplateFromFileの違い ]</span></div><div class="label-box-content block-box-content box-content">
<p class="has-cocoon-black-color has-text-color is-style-information-box has-box-style">createHtmlOutput～()&nbsp;系は読み込んだデータからそのまま&nbsp;HtmlOutput&nbsp;を生成します。対して、createTemplate～()&nbsp;系は&nbsp;HtmlTemplate&nbsp;を生成します。<br>HtmlTemplateはいわゆるテンプレートエンジンで、外部から動的に値を埋め込んだり条件分岐やループを使用してコンテンツをサーバーサイドで動的に変更することができます。(HtmlTemplate.evaluate()を呼ぶことでHtmlOutputに変換します。）</p>
</div></div>



<p>[ スクリプトの解説 ]</p>



<p><strong>function doGet() {</strong></p>



<p>doGet関数は、デプロイURLにアクセスした際に実行される特殊な関数です。doGet関数の引数eとすることで、デプロイURLにアクセスした際(GETリクエストを送った際に)URLに含まれるクエリやパラメーターを引き渡すことができます。</p>



<p><strong>const template = HtmlService.createTemplateFromFile(&#8220;index&#8221;)</strong></p>



<p>2行目のHtmlService.createTemplateFromFile(&#8220;index&#8221;)で、index.htmlファイルを読み込んで結果をtemplateという変数に代入しています。このtemplateは、HTMLとスクリプトが混在した状態のもので、まだこの時点ではブラウザで表示できる状態ではありません。</p>



<ul class="wp-block-list">
<li>HtmlServiceとはHtmlServiceオブジェクトのことで、Google Apps Scriptとやり取りをすることができるWebページを作成するためのHTMLファイルを操作する機能とセキュリティ(サニタイズ)を提供してくれます。GASでWebアプリケーションを作成するときは、HtmlServiceオブジェクトを使います。</li>



<li>HtmlServiceオブジェクトのメソッドであるcreateTemplateFromFileは、指定のhtmlファイルからHtmlTemplateオブジェクトを生成するメソッドです。HtmlTemplateオブジェクトは動的にHTMLを構築するためのテンプレートです。HtmlTemplateオブジェクトを使うことでスクリプトレットと呼ばれる動的にHTMLを生成する構文を使うことができます。(スクリプトレット構文を使うとHTMLの中にGASのコードを埋め込むことができます。)</li>
</ul>



<p><strong>const htmlOutput = template.evaluate();</strong></p>



<p>そこで3行目で、HtmlTemplateオブジェクトをevaluate(評価)することでHtmlOutputという形式のオブジェクトに変換しています。変換されたHtmlOutputオブジェクトはブラウザで表示ができる状態となります。<br>留意:<br>evaluate()とはHtmlTemplateオブジェクトをHtmlOutputオブジェクトに変換するメソッドです。HtmlOutputオブジェクトに変換することでWebページを表示できるようになります。</p>



<p><strong>return htmlOutput;</strong></p>



<p>このHtmlOutputオブジェクトをdoGet関数からreturnすることで、Webページに指定したHTMLファイルを表示することができます。なぜHtmlOutputオブジェクトに変換する必要があるかというと、doGet関数の戻り値としてHtmlOutputオブジェクトを返すことがGASで決まっているからです。</p>



<h4 class="wp-block-heading">公開</h4>



<p>右上の「デプロイ」から「新しいデプロイ」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="611" height="214" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0542.png" alt="公開手順1(新しいデプロイ)" class="wp-image-23066" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0542.png 611w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0542-300x105.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0542-500x175.png 500w" sizes="(max-width: 611px) 100vw, 611px" /></figure>



<h5 class="wp-block-heading">「ウェブアプリ」の選択</h5>



<p>「種類の選択」の歯車アイコンをクリックし、「ウェブアプリ」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="506" height="277" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0534.png" alt="公開手順2(ウェブアプリの選択)" class="wp-image-23060" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0534.png 506w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0534-300x164.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0534-500x274.png 500w" sizes="(max-width: 506px) 100vw, 506px" /></figure>



<h5 class="wp-block-heading">設定</h5>



<p>以下を設定して、右下の「デプロイ」をクリックします。</p>



<ul class="wp-block-list">
<li>「新しい説明文」にわかりやすい説明文を入力します。<br>ここでは「最初のデプロイ」と入力します。</li>



<li>「次のユーザーとして実行」で「自分（xxxxx@gmail.com）」を選択します。</li>



<li>「アクセスできるユーザー」で「Googleアカウントを持つ全員」を選択</li>
</ul>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="502" height="399" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0535.png" alt="公開手順3(デプロイの設定)" class="wp-image-23062" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0535.png 502w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0535-300x238.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0535-500x397.png 500w" sizes="(max-width: 502px) 100vw, 502px" /></figure>



<h5 class="wp-block-heading">デプロイの完了</h5>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="504" height="398" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0536.png" alt="公開手順4(デプロイの完了)" class="wp-image-23063" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0536.png 504w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0536-300x237.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0536-500x395.png 500w" sizes="(max-width: 504px) 100vw, 504px" /></figure>



<h5 class="wp-block-heading">公開</h5>



<p>ウェブアプリのURLをクリックしてWebページを表示してみましょう。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="569" height="184" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0537.png" alt="Webページの表示(GAS)" class="wp-image-23064" style="width:569px;height:184px" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0537.png 569w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0537-300x97.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0537-500x162.png 500w" sizes="(max-width: 569px) 100vw, 569px" /></figure>



<p>無事、HTMLファイルの内容が表示されていることが確認できました！</p>



<h2 class="wp-block-heading"><span id="toc6">ページタイトル、ファビコンの変更方法</span></h2>



<p>GasでHTMLを作成する場合、ページタイトルとファビコンについてはHTMLのheadタグ内に記述するのではなく、コード.gs内に記述する必要があります。</p>



<h3 class="wp-block-heading"><span id="toc7">ページタイトルを変更する。</span></h3>



<p><strong>siteTitleメソッド</strong>を使います。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="600" height="366" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0551.png" alt="ページタイトルの変更(GAS)" class="wp-image-23067" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0551.png 600w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0551-300x183.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0551-500x305.png 500w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<h3 class="wp-block-heading"><span id="toc8">ファビコンを変更する。</span></h3>



<p><strong>setFaviconUrlメソッド</strong>を使います。ファビコン画像はGoogleドライブ内に保存した画像を利用します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="600" height="358" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0552.png" alt="ファビコンの変更(GAS)" class="wp-image-23068" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0552.png 600w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0552-300x179.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0552-500x298.png 500w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>GoogleAppsScriptの始め方(ライブラリーの導入)</title>
		<link>https://gungii.com/gas04-info/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Wed, 12 Jul 2023 00:51:18 +0000</pubDate>
				<category><![CDATA[GAS]]></category>
		<category><![CDATA[ソフトウェア]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=23017</guid>

					<description><![CDATA[Google Apps Script(GAS)には「ライブラリ」と呼ばれる機能があります。これはGASで作成した関数を、別のプロジェクトでも利用することができる機能です。GASで作成したスクリプトをライブラリとして一般公 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Google Apps Script(GAS)には「ライブラリ」と呼ばれる機能があります。これはGASで作成した関数を、別のプロジェクトでも利用することができる機能です。GASで作成したスクリプトをライブラリとして一般公開したり、組織内や特定ユーザーに限定して公開することも可能です。また他の人が作成して公開しているライブラリを自身のスクリプトで利用することもできます。<br>ここでは他の人が公開しているライブラリを利用する方法と、自作のスクリプトをライブラリー化して他のプロジェクトで使える様にする方法についてご紹介します。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-8" checked><label class="toc-title" for="toc-checkbox-8">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">ライブラリーの導入</a><ol><li><a href="#toc2" tabindex="0">ライブラリーの追加</a></li></ol></li><li><a href="#toc3" tabindex="0">自作スクリプトのライブラリー化</a><ol><li><a href="#toc4" tabindex="0">自作スクリプトのライブラリー化</a></li><li><a href="#toc5" tabindex="0">別のプロジェクトから呼び出します。</a></li><li><a href="#toc6" tabindex="0">スクリプトの実行</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">ライブラリーの導入</span></h2>



<p>GoogleAppsScriptで実際にライブラリを導入する手順について解説します。どんなライブラリでも導入手順は同じです。</p>



<h3 class="wp-block-heading"><span id="toc2">ライブラリーの追加</span></h3>



<p>ここでは日付操作で人気のライブラリである dayjs を追加してみます。</p>



<h4 class="wp-block-heading">「ライブラリーの追加」をクリック</h4>



<p>スクリプトエディターの画面で、左側のメニューから「ライブラリー」の+ボタンをクリックします。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0401.png" alt="ライブラリーの追加手順1(GAS)" class="wp-image-23019" width="648" height="269" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0401.png 648w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0401-300x125.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0401-500x208.png 500w" sizes="(max-width: 648px) 100vw, 648px" /></figure>



<h4 class="wp-block-heading">スクリプトIDの入力</h4>



<p>スクリプトIDを入力して、「検索」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="403" height="383" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0402.png" alt="ライブラリーの追加手順2(GAS)" class="wp-image-23020" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0402.png 403w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0402-300x285.png 300w" sizes="(max-width: 403px) 100vw, 403px" /></figure>



<p>dayjsのスクリプトIDは、次の通りです。<br><strong>1ShsRhHc8tgPy5wGOzUvgEhOedJUQD53m-gd8lG2MOgs-dXC_aCZn9lFB</strong></p>



<h4 class="wp-block-heading">バージョンの選択</h4>



<p>「検索」すると、以下のような画面が表示されますので、バーションを選択して「追加」をクリックします。「バージョン」をプルダウンから選択。ここは最も数字の大きい最新のバージョンを選択すればOKです。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="402" height="390" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0403.png" alt="ライブラリーの追加手順3(GAS)" class="wp-image-23021" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0403.png 402w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0403-300x291.png 300w" sizes="(max-width: 402px) 100vw, 402px" /></figure>



<h4 class="wp-block-heading">導入の完了</h4>



<p>dayjsが左側のメニューに追加されました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="596" height="286" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0404.png" alt="ライブラリーの追加手順4(GAS)" class="wp-image-23022" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0404.png 596w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0404-300x144.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0404-500x240.png 500w" sizes="(max-width: 596px) 100vw, 596px" /></figure>



<h2 class="wp-block-heading"><span id="toc3">自作スクリプトのライブラリー化</span></h2>



<h3 class="wp-block-heading"><span id="toc4">自作スクリプトのライブラリー化</span></h3>



<p>自分で作ったスクリプトをライブラリー化して、他のプロジェクトから呼び出して利用できるようにします。</p>



<h4 class="wp-block-heading">自作関数の準備</h4>



<p>自作スクリプトとして、gokei関数を用意します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="569" height="163" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0411.png" alt="自作関数の準備(GAS)" class="wp-image-23023" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0411.png 569w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0411-300x86.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0411-500x143.png 500w" sizes="(max-width: 569px) 100vw, 569px" /></figure>



<pre class="wp-block-code"><code>function gokei(a,b) {
  return a + b;
}</code></pre>



<h4 class="wp-block-heading">ライブラリーの公開</h4>



<p>この関数をライブラリー化します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="568" height="174" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0412.png" alt="自作関数のライブラリー化手順1(GAS)" class="wp-image-23024" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0412.png 568w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0412-300x92.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0412-500x153.png 500w" sizes="(max-width: 568px) 100vw, 568px" /></figure>



<h5 class="wp-block-heading">ライブラリーをクリック</h5>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0413.png" alt="自作関数のライブラリー化手順2(GAS)" class="wp-image-23025" width="474" height="376" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0413.png 466w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0413-300x238.png 300w" sizes="(max-width: 474px) 100vw, 474px" /></figure>



<h5 class="wp-block-heading">説明文の入力</h5>



<p>説明文を入力して、「デプロイ」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="465" height="368" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0414.png" alt="自作関数のライブラリー化手順3(GAS)" class="wp-image-23026" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0414.png 465w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0414-300x237.png 300w" sizes="(max-width: 465px) 100vw, 465px" /></figure>



<h5 class="wp-block-heading">「完了」をクリック</h5>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="463" height="369" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0415.png" alt="自作関数のライブラリー化手順4(GAS)" class="wp-image-23027" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0415.png 463w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0415-300x239.png 300w" sizes="(max-width: 463px) 100vw, 463px" /></figure>



<h4 class="wp-block-heading">共有の設定</h4>



<p>このライブラリーを他のユーザーからも使用できるようにする為に、共有を設定します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="617" height="98" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0416.png" alt="プロジェクトの共有手順1(GAS)" class="wp-image-23028" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0416.png 617w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0416-300x48.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0416-500x79.png 500w" sizes="(max-width: 617px) 100vw, 617px" /></figure>



<p>ここでは、「リンクを知っている全員」を選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="616" height="566" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0417.png" alt="プロジェクトの共有手順2(GAS)" class="wp-image-23029" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0417.png 616w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0417-300x276.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0417-500x459.png 500w" sizes="(max-width: 616px) 100vw, 616px" /></figure>



<p>これで、ライブラリーとしてこのプロジェクトが公開されました。</p>



<h3 class="wp-block-heading"><span id="toc5">別のプロジェクトから呼び出します。</span></h3>



<p>それでは、別のプロジェクト(ここでは「無題のプロジェクト」)からこのライブラリーを使ってみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="614" height="185" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0418.png" alt="スクリプトエディターの画面(GAS)" class="wp-image-23030" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0418.png 614w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0418-300x90.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0418-500x151.png 500w" sizes="(max-width: 614px) 100vw, 614px" /></figure>



<h4 class="wp-block-heading">ライブラリーの追加</h4>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0419.png" alt="ライブラリーの追加(GAS)" class="wp-image-23031" width="623" height="374" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0419.png 625w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0419-300x180.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0419-500x300.png 500w" sizes="(max-width: 623px) 100vw, 623px" /></figure>



<h5 class="wp-block-heading">スクリプトIDの入力</h5>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="393" height="372" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0420.png" alt="スクリプトIDの入力(GAS)" class="wp-image-23032" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0420.png 393w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0420-300x284.png 300w" sizes="(max-width: 393px) 100vw, 393px" /></figure>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box has-border-color has-orange-border-color"><div class="label-box-label block-box-label box-label fab-edit"><span class="label-box-label-text block-box-label-text box-label-text">[ スクリプトIDの取得方法 ]</span></div><div class="label-box-content block-box-content box-content">
<p>スクリプトIDは、liblalyプロジェクトのURLの中の部分となります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="592" height="81" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0421.png" alt="スクリプトIDの取得方法1(GAS)" class="wp-image-23033" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0421.png 592w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0421-300x41.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0421-500x68.png 500w" sizes="(max-width: 592px) 100vw, 592px" /></figure>



<p>又は、歯車アイコンの設定メニューからスクリプトのIDをコピーします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="535" height="341" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0422.png" alt="スクリプトIDの取得方法2(GAS)" class="wp-image-23034" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0422.png 535w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0422-300x191.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0422-500x319.png 500w" sizes="(max-width: 535px) 100vw, 535px" /></figure>
</div></div>



<h5 class="wp-block-heading">「検索」をクリック</h5>



<p>スクリプトIDを入力して「検索」をクリックすると、バージョンの選択とライブラリ用のIDを入力する欄が表示されます。ここでは、バージョンは「HEAD」、IDはliblary01と入力して「追加」をクリックします。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0423.png" alt="ライブラリーの検索(GAS)" class="wp-image-23035" width="385" height="371" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0423.png 385w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0423-300x289.png 300w" sizes="(max-width: 385px) 100vw, 385px" /></figure>



<p>バージョンをHEAD（開発モード）にしておくと、常に最新のバージョンのライブラリを使用することができます。</p>



<h4 class="wp-block-heading">ライブラリーの追加完了</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="617" height="185" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0424.png" alt="ライブラリーの追加完了" class="wp-image-23036" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0424.png 617w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0424-300x90.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0424-500x150.png 500w" sizes="(max-width: 617px) 100vw, 617px" /></figure>



<p>「liblary」が追加されますので、ライブラリーがつかえるようになります。</p>



<h3 class="wp-block-heading"><span id="toc6">スクリプトの実行</span></h3>



<p>ここでは「無題のプロジェクト」からgokei関数を呼び出し、スクリプトを実行してみます。</p>



<h4 class="wp-block-heading">スクリプトの作成</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="616" height="109" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0425.png" alt="スクリプトの作成(GAS)" class="wp-image-23037" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0425.png 616w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0425-300x53.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0425-500x88.png 500w" sizes="(max-width: 616px) 100vw, 616px" /></figure>



<p>gokei関数の呼び出し</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="618" height="184" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0426.png" alt="自作関数の呼び出し(GAS)" class="wp-image-23038" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0426.png 618w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0426-300x89.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0426-500x149.png 500w" sizes="(max-width: 618px) 100vw, 618px" /></figure>



<pre class="wp-block-code"><code>function myFunction() {
  let total = liblary01.gokei(5,7);
  Logger.log(total);
  
}</code></pre>



<h4 class="wp-block-heading">スクリプトの実行</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="617" height="244" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0427.png" alt="スクリプトの実行(GAS)" class="wp-image-23039" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0427.png 617w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0427-300x119.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0427-500x198.png 500w" sizes="(max-width: 617px) 100vw, 617px" /></figure>



<p>他のプロジェクトから、gokei関数を呼びたし、スクリプトを実行できました。このようにプロジェクトをライブラリー化しておくと、他のプロジェクトでライブラリの関数を使うことができるようになります。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>GoogleAppsScriptの始め方(Googleドライブの扱い方)</title>
		<link>https://gungii.com/gas03-info/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Tue, 11 Jul 2023 22:41:39 +0000</pubDate>
				<category><![CDATA[GAS]]></category>
		<category><![CDATA[ソフトウェア]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=22959</guid>

					<description><![CDATA[GoogleAppsScriptで、Googleドライブのファイルやフォルダを扱う場合のGASでの扱い方について解説をします。「GoogleAppsScriptの使い方(基本的な使い方)」では、スプレッドシートに紐づいた [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>GoogleAppsScriptで、Googleドライブのファイルやフォルダを扱う場合のGASでの扱い方について解説をします。「GoogleAppsScriptの使い方(基本的な使い方)」では、スプレッドシートに紐づいたコンテナバインドスクリプトを中心に解説をしました。が、今回は、Googleドライブに対して操作を行う、ドライブ上で独立して動作するスタンドアロンスクリプトについて解説をします。実務で良くあるフォルダやファイルの整理を自動化のスクリプトを作成しながら、Googleドライブに対する操作をご紹介します。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-10" checked><label class="toc-title" for="toc-checkbox-10">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">Googleドライブの扱い方</a><ol><li><a href="#toc2" tabindex="0">フォルダの取得</a></li><li><a href="#toc3" tabindex="0">ファイルの取得</a></li></ol></li><li><a href="#toc4" tabindex="0">ファイル整理の自動化</a><ol><li><a href="#toc5" tabindex="0">ファイル整理自動化の内容</a></li><li><a href="#toc6" tabindex="0">ファイル整理自動化の準備</a></li><li><a href="#toc7" tabindex="0">自動化スクリプトの作成</a></li><li><a href="#toc8" tabindex="0">自動化スクリプトの実行</a></li></ol></li><li><a href="#toc9" tabindex="0">承認手続き</a><ol><li><a href="#toc10" tabindex="0">権限を確認</a></li><li><a href="#toc11" tabindex="0">「詳細」をクリック</a></li><li><a href="#toc12" tabindex="0">「許可」をクリック</a></li></ol></li><li><a href="#toc13" tabindex="0">配列の重複を削除する方法</a><ol><li><a href="#toc14" tabindex="0">filterメソッド</a></li></ol></li><li><a href="#toc15" tabindex="0">存在チェックの方法</a><ol><li><a href="#toc16" tabindex="0">処理内容</a></li><li><a href="#toc17" tabindex="0">スクリプトの作成</a></li><li><a href="#toc18" tabindex="0">スクリプトの検証</a></li><li><a href="#toc19" tabindex="0">スクリプトの実行</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">Googleドライブの扱い方</span></h2>



<p>GASで、Googleドライブのファイルやフォルダを扱う場合は、DriveAppクラスを使います。DriveAppクラスの各種メソッドを使って各種操作を行います。<br>以下のようなGoogleドライブの構成を例として、フォルダの取得、ファイルの取得のメソッドをご紹介します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="595" height="130" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0301.png" alt="フォルダ・ファイルの構成(Googleドライブ)" class="wp-image-22962" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0301.png 595w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0301-300x66.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0301-500x109.png 500w" sizes="(max-width: 595px) 100vw, 595px" /></figure>



<h3 class="wp-block-heading"><span id="toc2">フォルダの取得</span></h3>



<p>まず、マイドライブの中の「業務フォルダ」を取得してみます。</p>



<h4 class="wp-block-heading">フォルダの取得方法</h4>



<p>GASでGoogleドライブのフォルダを取得する場合は、DriveAppのgetFolderByIdメソッドを使います。フォルダIDであればGoogleドライブでそのフォルダを開いている際のURLの以下の部分です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="484" height="369" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0302.png" alt="フォルダID(GAS)" class="wp-image-22963" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0302.png 484w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0302-300x229.png 300w" sizes="(max-width: 484px) 100vw, 484px" /></figure>



<h4 class="wp-block-heading">DriveAppクラスからフォルダを取得する。</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="596" height="282" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0304.png" alt="フォルダの取得方法(GAS)" class="wp-image-22964" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0304.png 596w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0304-300x142.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0304-500x237.png 500w" sizes="(max-width: 596px) 100vw, 596px" /></figure>



<pre class="wp-block-code"><code>function myFunction() {
  const folder = DriveApp.getFolderById("フォルダID");
  console.log(folder.getName());
}</code></pre>



<p>スクリプトで使用されているgetNameメソッドはフォルダ名を取得するメソッドです。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0305.png" alt="フォルダ名の取得(GAS)" class="wp-image-22965" width="346" height="49" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0305.png 346w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0305-300x42.png 300w" sizes="(max-width: 346px) 100vw, 346px" /></figure>



<h3 class="wp-block-heading"><span id="toc3">ファイルの取得</span></h3>



<p>次に、「業務フォルダ」内に保存されていたファイル「シートの取得用」を取得してみます。</p>



<h4 class="wp-block-heading">ファイルの取得方法</h4>



<p>Googleドライブのファイルを取得する場合は、DriveAppのgetFileByIdメソッドを使います。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="600" height="277" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0306.png" alt="ファイルの取得(GAS)" class="wp-image-22966" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0306.png 600w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0306-300x139.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0306-500x231.png 500w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<pre class="wp-block-code"><code>function myFunction() {
  const file = DriveApp.getFileById("ファイルID");
  console.log(file.getName());
}</code></pre>



<p>※ファイルIDは、以下の通り</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="593" height="90" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0307a.png" alt="" class="wp-image-23010" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0307a.png 593w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0307a-300x46.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0307a-500x76.png 500w" sizes="(max-width: 593px) 100vw, 593px" /></figure>



<h4 class="wp-block-heading">全てのファイルを取得する。</h4>



<p>「<strong>const files = DriveApp.getFiles();</strong>」が、Googleドライブのすべてのファイルを取得するスクリプトになります。取得したデータは「FileIterator（ファイルイテレータ）」という形式です。イテレータを使えばデータの集まりに対して、「次」、「次」と抽象的に命令するだけで、順番に各データを取得することができます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="635" height="481" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0308.png" alt="全てのファイルの取得(GAS)" class="wp-image-22968" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0308.png 635w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0308-300x227.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0308-500x379.png 500w" sizes="(max-width: 635px) 100vw, 635px" /></figure>



<pre class="wp-block-code"><code>function myFunction() {
  const files = DriveApp.getFiles();
  while (files.hasNext()) {
    const file = files.next();
    console.log(file.getName());    
  }
}</code></pre>



<h4 class="wp-block-heading">特定のフォルダーの中のファイルを全て取得する。</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="660" height="475" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0310.png" alt="特定フォルダのファイルの取得(GAS)" class="wp-image-22969" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0310.png 660w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0310-300x216.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0310-500x360.png 500w" sizes="(max-width: 660px) 100vw, 660px" /></figure>



<pre class="wp-block-code"><code>const gyomuFolder = DriveApp.getFolderById("フォルダID");

function myFunction() {
  const files = gyomuFolder.getFiles();
  while (files.hasNext()) {
    const file = files.next();
    console.log(file.getName());    
  }
}</code></pre>



<h2 class="wp-block-heading"><span id="toc4">ファイル整理の自動化</span></h2>



<p>それでは、実際に実務で良くある「フォルダの整理」「ファイルの整理」をスクリプトを作成して自動化してみます。</p>



<h3 class="wp-block-heading"><span id="toc5">ファイル整理自動化の内容</span></h3>



<p>「ドキュメント」フォルダ内のファイルの内、ファイルの最終更新日が1ヶ月以上前のファイルについては、「old」フォルダ内に新しく「年月」のフォルダを作成して移動させます。<br>※わかりやすいようにファイル名は、最終更新日としています。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="619" height="366" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0311.png" alt="ファイル整理自動化のイメージ(GAS)" class="wp-image-22970" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0311.png 619w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0311-300x177.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0311-500x296.png 500w" sizes="(max-width: 619px) 100vw, 619px" /></figure>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box has-border-color has-orange-border-color"><div class="label-box-label block-box-label box-label fab-edit"><span class="label-box-label-text block-box-label-text box-label-text">[ スクリプト実行前の「ドキュメント」フォルダ ]</span></div><div class="label-box-content block-box-content box-content">
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="574" height="362" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0312.png" alt="スクリプト実行前の「ドキュメント」フォルダ" class="wp-image-22971" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0312.png 574w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0312-300x189.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0312-500x315.png 500w" sizes="(max-width: 574px) 100vw, 574px" /></figure>
</div></div>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box has-border-color has-light-green-border-color"><div class="label-box-label block-box-label box-label fab-edit"><span class="label-box-label-text block-box-label-text box-label-text">[ スクリプト実行後 の「ドキュメント」フォルダ]</span></div><div class="label-box-content block-box-content box-content">
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="603" height="847" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0313.png" alt="スクリプト実行後の「ドキュメント」フォルダ" class="wp-image-22972" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0313.png 603w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0313-300x421.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0313-500x702.png 500w" sizes="(max-width: 603px) 100vw, 603px" /></figure>
</div></div>



<h3 class="wp-block-heading"><span id="toc6">ファイル整理自動化の準備</span></h3>



<h4 class="wp-block-heading">作成する関数(スクリプト)</h4>



<h5 class="wp-block-heading">seiriFiles関数</h5>



<p>「ドキュメント」フォルダ内のファイルを調べて、最終更新日が1ヶ月以上前のファイルを取得します。</p>



<h5 class="wp-block-heading">sakuseiFolder関数</h5>



<p>seiriFiles関数から呼び出され、移動対象となるファイルを取得して「old」フォルダ内に「年月」フォルダを作成します。</p>



<h5 class="wp-block-heading">idouFiles関数</h5>



<p>seiriFiles関数から呼び出され、sakuseiFolder関数で作成した「年月」フォルダに移動対象のファイルを移動させます。</p>



<h4 class="wp-block-heading">ライブラリーの導入</h4>



<p>このスクリプトでは、日付データを扱いますので「dayjs」というライブラリーを導入します。<br>dayjsのスクリプトIDは、</p>



<p>1ShsRhHc8tgPy5wGOzUvgEhOedJUQD53m-gd8lG2MOgs-dXC_aCZn9lFB</p>



<h3 class="wp-block-heading"><span id="toc7">自動化スクリプトの作成</span></h3>



<p>それでは、スクリプトを作っていきます。</p>



<h4 class="wp-block-heading">スクリプトエディターを開く</h4>



<p>今回は、Googleドライブ上で独立して動作するスタンドアロンスクリプトを作成します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="631" height="724" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0321.png" alt="スクリプトエディターの起動(GAS)" class="wp-image-22973" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0321.png 631w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0321-300x344.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0321-500x574.png 500w" sizes="(max-width: 631px) 100vw, 631px" /></figure>



<h4 class="wp-block-heading">seiriFiles関数の実装</h4>



<p>「ドキュメント」フォルダ内のファイルを調べて、最終更新日が1ヶ月以上前のファイルを取得します。プロジェクト名は、「ファイルの整理」、ファイル名はコード.gs、関数名はseiriFilesとします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="612" height="175" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0322.png" alt="seiriFiles関数の実装1(GAS)" class="wp-image-22974" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0322.png 612w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0322-300x86.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0322-500x143.png 500w" sizes="(max-width: 612px) 100vw, 612px" /></figure>



<h5 class="wp-block-heading">フォルダ内のファイルの取得</h5>



<p>getFiolderByIdメソッドで「ドキュメント」フォルダを取得してgetFilesメソッドで、「ドキュメント」フォルダ内のファイルを全て取得してfilesに格納します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="615" height="165" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0323.png" alt="seiriFiles関数の実装2(GAS)" class="wp-image-22975" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0323.png 615w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0323-300x80.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0323-500x134.png 500w" sizes="(max-width: 615px) 100vw, 615px" /></figure>



<pre class="wp-block-code"><code>function seiriFiles() {
  const documentFolder = DriveApp.getFolderById("フォルダID");
  const files = documentFolder.getFiles();</code></pre>



<p>3行目の「getFiles();」が、「ドキュメント」フォルダ内の全てのファイルを取得するスクリプトになります。取得したデータは「FileIterator(ファイルイテレータ)」という形式です。イテレータを使えばデータの集まりに対して「次」「次」と抽象的に命令するだけで、順番に各データを取得することができます。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-orange-border-color"><div class="tab-caption-box-label block-box-label box-label fab-edit"><span class="tab-caption-box-label-text block-box-label-text box-label-text">[ 全てのファイルが取得されているかを確認 ]</span></div><div class="tab-caption-box-content block-box-content box-content">
<p>filesにファイルが格納されているか確認してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="616" height="586" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0324.png" alt="seiriFiles関数の実装3(GAS)" class="wp-image-22976" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0324.png 616w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0324-300x285.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0324-500x476.png 500w" sizes="(max-width: 616px) 100vw, 616px" /></figure>



<p>[確認の為のスクリプトの解説]</p>



<p>「while (files.hasNext()) {」は、filesに次のデータがある限り処理を続けます。<br>「const file = files.next();」で、files（「ドキュメント」フォルダにあるファイル）の次のデータを取得しています。<br>「Logger.log(file.getName());」が「const file = files.next();」で取得したデータに対する処理になります。今回は取得したデータの名前をログに表示させています。</p>
</div></div>



<h5 class="wp-block-heading">1ヶ月前の日付の取得</h5>



<p>現在の日付から1ヶ月前の日付を取得します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="521" height="83" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0325.png" alt="seiriFiles関数の実装4(GAS)" class="wp-image-22977" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0325.png 521w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0325-300x48.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0325-500x80.png 500w" sizes="(max-width: 521px) 100vw, 521px" /></figure>



<p>dateオブジェクト.setMonth(引数)で、dateオブジェクトの月から1ヶ月前の日付をセットします。</p>



<p>留意:<br>taisyoFiles = [ ];は移動対象のファイルオブジェクトを格納する配列で、<br>folderNames=[ ];は、作成するフォルダ名を格納する配列となります。</p>



<p>[ hitothukimaeの内容を確認します。]</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="586" height="308" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0326.png" alt="seiriFiles関数の実装5(GAS)" class="wp-image-22978" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0326.png 586w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0326-300x158.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0326-500x263.png 500w" sizes="(max-width: 586px) 100vw, 586px" /></figure>



<p>現在日付が2023/07/07ですので、1ヶ月前の2023/06/07となっています。</p>



<p>注意:<br>formatは、&#8221;yyyy/MM/DD&#8221;ではなく、&#8221;yyyy/MM/dd&#8221;となりますので、ご注意下さい。&#8221;yyyy/MM/DD&#8221;だと、以下のように158と変な数値となってしまいます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="592" height="154" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0327.png" alt="" class="wp-image-22980" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0327.png 592w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0327-300x78.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0327-500x130.png 500w" sizes="(max-width: 592px) 100vw, 592px" /></figure>



<h5 class="wp-block-heading">最終更新日のチェックと対象ファイルの格納</h5>



<p>次に、whileとhasNextメソッド、nextメソッドで「ドキュメント」フォルダから取得したファイルの最終更新日が1ヶ月以上前か否かをチェックします。<br>※ファイルの最終更新日を取得するには、getLastUpdated()メソッドを使用します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="558" height="134" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0328.png" alt="seiriFiles関数の実装7(GAS)" class="wp-image-22981" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0328.png 558w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0328-300x72.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0328-500x120.png 500w" sizes="(max-width: 558px) 100vw, 558px" /></figure>



<p>最終更新日(lastUpdated.getTime())の方が、現在日付の1ヶ月前の日付(hitothukimae.getTime())より前の日付だった場合は配列(taisyoFiles)にファイルを格納します。そして最終更新日からYYYYMM形式の文字列を生成してfolderNamesに格納します。<br>※getTime() ではDate型の日付をミリ秒に変換した数値を返却してくれます。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-orange-border-color"><div class="tab-caption-box-label block-box-label box-label fab-edit"><span class="tab-caption-box-label-text block-box-label-text box-label-text">[ taisyoFilesの確認 ]</span></div><div class="tab-caption-box-content block-box-content box-content">
<p>taisyoFilesの配列に移動対象のファイルが格納されているかを確認します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="586" height="485" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0329.png" alt="seiriFiles関数の検証1(GAS)" class="wp-image-22982" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0329.png 586w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0329-300x248.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0329-500x414.png 500w" sizes="(max-width: 586px) 100vw, 586px" /></figure>
</div></div>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-amber-border-color"><div class="tab-caption-box-label block-box-label box-label fab-edit"><span class="tab-caption-box-label-text block-box-label-text box-label-text">[ folderNamesの確認 ]</span></div><div class="tab-caption-box-content block-box-content box-content">
<p>folderNamesの配列に移動対象のファイルが格納されているかを確認します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="587" height="240" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0330.png" alt="seiriFiles関数の検証2(GAS)" class="wp-image-22983" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0330.png 587w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0330-300x123.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0330-500x204.png 500w" sizes="(max-width: 587px) 100vw, 587px" /></figure>
</div></div>



<h5 class="wp-block-heading">関数の呼び出し</h5>



<p>sakuseiFolderと、idouFilesを呼び出します。sakuseiFolderの引数はfolderNamesで、idouFilesの引数は配列taisyoFilesと変数documentFolder(「ドキュメントフォルダ」のFileオブジェクト)です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="367" height="47" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0331.png" alt="関数の呼び出し(GAS)" class="wp-image-22984" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0331.png 367w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0331-300x38.png 300w" sizes="(max-width: 367px) 100vw, 367px" /></figure>



<h5 class="wp-block-heading">seiriFiles関数の全体</h5>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="618" height="364" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0332.png" alt="seiFiles関数の全体" class="wp-image-23015" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0332.png 618w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0332-300x177.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0332-500x294.png 500w" sizes="(max-width: 618px) 100vw, 618px" /></figure>



<pre class="wp-block-code"><code>function seiriFiles() {
  const documentFolder = DriveApp.getFolderById("フォルダID");
  const files = documentFolder.getFiles();

  let hitothukimae = new Date();
  hitothukimae.setMonth(hitothukimae.getMonth() - 1);
  let taisyoFiles = &#91;]; //移動対象のファイルオブジェクトを格納する配列
  let folderNames = &#91;]; //作成するフォルダー名を格納する配列

  while (files.hasNext()) {
    let file = files.next();
    let lastUpdated = file.getLastUpdated();
    if (lastUpdated.getTime() &lt; hitothukimae.getTime()) {
      taisyoFiles.push(file);
      folderNames.push(dayjs.dayjs(new Date(lastUpdated)).format("YYYYMM"));
    }
  }

  sakuseiFolder(folderNames);
  idouFiles(taisyoFiles,documentFolder);
}</code></pre>



<h4 class="wp-block-heading">sakuseiFolder関数の実装</h4>



<p>seiriFiles関数より呼ばれるsakuseiFolder関数を実装します。この関数でfolderNamesの配列に格納されているフォルダー名を取り出し「old」フォルダの中にそのフォルダ名で、フォルダを作成します。</p>



<h5 class="wp-block-heading">フォルダ名の重複チェック</h5>



<p>まずfilter関数で、folderNamesに格納されているフォルダ名を抽出して重複がない様にチェックしながら、newlistという新しい配列を生成します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="539" height="74" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0333.png" alt="sakuseiFolder関数の実装1" class="wp-image-22987" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0333.png 539w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0333-300x41.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0333-500x69.png 500w" sizes="(max-width: 539px) 100vw, 539px" /></figure>



<p>※スクリプトの解説は、<a href="#cyofuku">「配列の重複を削除する方法」</a>を参照願います。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-orange-border-color"><div class="tab-caption-box-label block-box-label box-label fab-edit"><span class="tab-caption-box-label-text block-box-label-text box-label-text">[ newlistの確認 ]</span></div><div class="tab-caption-box-content block-box-content box-content">
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="540" height="329" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0334.png" alt="sakuseiFolder関数の実装2" class="wp-image-22988" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0334.png 540w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0334-300x183.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0334-500x305.png 500w" sizes="(max-width: 540px) 100vw, 540px" /></figure>
</div></div>



<h5 class="wp-block-heading">フォルダの作成</h5>



<p>配列newListに格納されている名前でYYYYMMフォルダを作成します。但し、このスクリプトを2回以上実行した場合は、初回の実行で作成されたYYYYMMフォルダと同じフォルダが存在する可能性がある為、IF文で確認(存在チェック)して作成します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="611" height="124" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0335.png" alt="sakuseiFolder関数の実装3" class="wp-image-22989" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0335.png 611w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0335-300x61.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0335-500x101.png 500w" sizes="(max-width: 611px) 100vw, 611px" /></figure>



<ul class="wp-block-list">
<li>「old」フォルダを取得します。<br>const oldFolder = DriveApp.getFolderById(&#8220;フォルダID&#8221;);</li>



<li>フォルダが重複しない様にチェック<br>if (!oldFolder.getFoldersByName(newlist[i]).hasNext()) {<br>　　　　oldFolder.createFolder(newlist[i]);<br>}</li>
</ul>



<p>[ スクリプトの解説 ]<br>getFoldersByNameメソッドもFolderIteratorを返しますので、イテレータの処理をしてフォルダ名を取得しています。newlistの配列に格納されているフォルダ名を次、次と取り出し同じフォルダ名があれば、trueを返しますが、!の論理演算子がついている為、falseを返します。つまり同じフォルダ名が無い時にoldFolder.createFolder(newlist[i]);が、実行されます。<br>※詳細は、<a href="#sonzaicheck">「存在チェックの方法」</a>を参照願います。</p>



<h5 class="wp-block-heading">sakuseiFolder関数の全体</h5>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="624" height="238" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0336-1.png" alt="sakuseiFolder関数の全体" class="wp-image-22990" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0336-1.png 624w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0336-1-300x114.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0336-1-500x191.png 500w" sizes="(max-width: 624px) 100vw, 624px" /></figure>



<pre class="wp-block-code"><code>function sakuseiFolder(folderNames) {
  const newlist = folderNames.filter(function (value, index, self) {
    return self.indexOf(value) === index;
  });
  const oldFolder = DriveApp.getFolderById("フォルダID");

  for (let i = 0; i &lt; newlist.length; i++) {
    if (!oldFolder.getFoldersByName(newlist&#91;i]).hasNext()) {
      oldFolder.createFolder(newlist&#91;i]);
    }
  }
}</code></pre>



<h4 class="wp-block-heading">idouFiles関数の実装</h4>



<p>seiriFiles関数より呼ばれるidouFiles関数を実装します。この関数でtaisyouFilesの配列に格納されているファイル名を取り出し、「old」フォルダの中の最終更新日と一致するフォルダ名のフォルダにファイルを移動させます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="640" height="165" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0337.png" alt="idouFiles関数の実装" class="wp-image-22991" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0337.png 640w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0337-300x77.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0337-500x129.png 500w" sizes="(max-width: 640px) 100vw, 640px" /></figure>



<h5 class="wp-block-heading">配列taisyoFilesからファイルの取り出し</h5>



<p><strong>for (let i=0; i&lt;taisyoFiles.length; i++) {</strong><br>引数で受け取った配列taisyoFiles(移動対象のファイルが格納されている)の要素数(taisyoFiles.length)だけ繰り返し処理を実行します。<br><strong>let lastUpdated = taisyoFiles[i].getLastUpdated();</strong><br>処理の中では、移動対象ファイルの最終更新日をgetLastUpdated()メソッドで、改めて取得して、</p>



<h5 class="wp-block-heading">移動先のフォルダ名を取得</h5>



<p><strong>let taisyoFolder = oldFolder.getFoldersByName(name).next();</strong><br>getFoldersByNameでフォルダ名を取得して、変数taisyoFolderに格納します。<br>※nameには、lastUpdatedから取得した最終更新日をYYYYMMのformatに変換する次のオーダーを記載します。<br><strong>dayjs.dayjs(new Date(lastupdated)).format(&#8220;YYYYMM&#8221;))</strong></p>



<h5 class="wp-block-heading">ファイルの移動</h5>



<p><strong>taisyoFiles[i].moveTo(taisyoFolder);</strong><br>配列taisyoFilesから取り出したファイルをmoveToメソッドでtaisyoFolderに移動させます。</p>



<h4 class="wp-block-heading">スクリプト全体の掲載</h4>



<p>スクリプト全体を掲載しておきます。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0338.png" alt="コード.gsの全体" class="wp-image-22992" width="647" height="580" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0338.png 647w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0338-300x269.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0338-500x448.png 500w" sizes="(max-width: 647px) 100vw, 647px" /></figure>



<pre class="wp-block-code"><code>function seiriFiles() {
  const documentFolder = DriveApp.getFolderById("フォルダID");
  const files = documentFolder.getFiles();

  let hitothukimae = new Date();
  hitothukimae.setMonth(hitothukimae.getMonth() - 1);
  let taisyoFiles = &#91;]; //移動対象のファイルオブジェクトを格納する配列
  let folderNames = &#91;]; //作成するフォルダー名を格納する配列

  while (files.hasNext()) {
    let file = files.next();
    let lastUpdated = file.getLastUpdated();
    if (lastUpdated.getTime() &lt; hitothukimae.getTime()) {
      taisyoFiles.push(file);
      folderNames.push(dayjs.dayjs(new Date(lastUpdated)).format("YYYYMM"));
    }
  }

  sakuseiFolder(folderNames);
  idouFiles(taisyoFiles,documentFolder);
}
function sakuseiFolder(folderNames) {
  const newlist = folderNames.filter(function (value, index, self) {
    return self.indexOf(value) === index;
  });
  const oldFolder = DriveApp.getFolderById("フォルダID");

  for (let i = 0; i &lt; newlist.length; i++) {
    if (!oldFolder.getFoldersByName(newlist&#91;i]).hasNext()) {
      oldFolder.createFolder(newlist&#91;i]);
    }
  }
}
function idouFiles(taisyoFiles,documentFolder) {
  const oldFolder = DriveApp.getFolderById("フォルダID")

  for (let i = 0; i &lt; taisyoFiles.length; i++) {

    let lastUpdated = taisyoFiles&#91;i].getLastUpdated();
    let taisyoFolder = oldFolder.getFoldersByName(dayjs.dayjs(new Date(lastUpdated)).format("YYYYMM")).next();
    taisyoFiles&#91;i].moveTo(taisyoFolder);
  };
};</code></pre>



<h3 class="wp-block-heading"><span id="toc8">自動化スクリプトの実行</span></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="482" height="166" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0339.png" alt="自動化スクリプトの実行1" class="wp-image-22993" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0339.png 482w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0339-300x103.png 300w" sizes="(max-width: 482px) 100vw, 482px" /></figure>



<p>スクリプトを初回実行するとき次のような承認画面が表示された場合は承認作業を行ってください。<br>手順は<a href="#syonin">こちら</a>。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="434" height="131" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0340.png" alt="自動化スクリプトの実行2" class="wp-image-22994" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0340.png 434w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0340-300x91.png 300w" sizes="(max-width: 434px) 100vw, 434px" /></figure>



<p>スクリプトの実行結果は、以下の通りです。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="619" height="366" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0311.png" alt="ファイル整理自動化のイメージ(GAS)" class="wp-image-22970" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0311.png 619w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0311-300x177.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0311-500x296.png 500w" sizes="(max-width: 619px) 100vw, 619px" /></figure>



<h2 class="wp-block-heading" id="syonin"><span id="toc9">承認手続き</span></h2>



<p>スプレッドシートやフォームなどのサービスと連携させる処理を行うと初回起動時のみ承認作業が必要です。アクセス許可が必要なのは、アカウント毎ではなく、1つのアプリ(スプレッドシート毎)に対して必ず1度承認しないといけません。</p>



<h3 class="wp-block-heading"><span id="toc10">権限を確認</span></h3>



<p>最初に実行する場合は、認証が必要となります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="542" height="282" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0341.png" alt="スクリプトの承認手順1" class="wp-image-22995" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0341.png 542w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0341-300x156.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0341-500x260.png 500w" sizes="(max-width: 542px) 100vw, 542px" /></figure>



<h3 class="wp-block-heading"><span id="toc11">「詳細」をクリック</span></h3>



<p>「詳細」から「無題のプロジェクト(安全ではないページ)に移動」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="553" height="265" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0342.png" alt="スクリプトの承認手順2" class="wp-image-22996" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0342.png 553w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0342-300x144.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0342-500x240.png 500w" sizes="(max-width: 553px) 100vw, 553px" /></figure>



<h3 class="wp-block-heading"><span id="toc12">「許可」をクリック</span></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="259" height="391" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0343.png" alt="スクリプトの承認手順3" class="wp-image-22997"/></figure>



<h2 class="wp-block-heading" id="cyofuku"><span id="toc13">配列の重複を削除する方法</span></h2>



<p>GASで配列の重複要素を削除する方法（ユニーク要素の配列にする方法）をご紹介します。filterメソッドを適応して配列の重複を削除します。</p>



<h3 class="wp-block-heading"><span id="toc14">filterメソッド</span></h3>



<p>filterの中で特定の条件を与えて配列データを取得したい内容を「コールバック関数」に書くことで、任意のデータを抽出して新しい配列を生成します。<br>[ 基本構文 ]<br>var items = 配列データ;<br>items.filter(コールバック関数)</p>



<h4 class="wp-block-heading">コールバック関数</h4>



<p>コールバック関数は、3つの引数を受け取ることができます。<br><strong>items.filter( function( value, index, array ) {</strong><br><strong>}</strong></p>



<ul class="wp-block-list">
<li>value:配列の値</li>



<li>index:配列のインデックス番号</li>



<li>array(self):現在処理している配列</li>
</ul>



<p>※function(value,index,array)としていますが、変数名は任意です。</p>



<h4 class="wp-block-heading">サンプルスクリプト</h4>



<p>以下は、配列の重複除外スクリプトです。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="475" height="284" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0351.png" alt="配列の重複除外スクリプト(GAS)" class="wp-image-22998" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0351.png 475w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0351-300x179.png 300w" sizes="(max-width: 475px) 100vw, 475px" /></figure>



<p>繰り返し処理をしている最中の配列の値が第1引数に、第2引数にはインデックス、第3引数にはitems配列が入っている状態となります。function内部でのreturnでTrueかFalseを判定して、filterではTrueとしたものだけを残す様になっています。配列.indexOfで最初に見つけた文字列のインデックス情報を返します。最初のりんごはインデックス0なので、そのまま→0 === 0 =&gt;True、最後のりんごはインデックス3となりますが、self.indexOf(りんご)とした場合には0となりますので、0 === 3 =&gt;Falseとなり、最後のりんごは除外されています。</p>



<p></p>



<h2 class="wp-block-heading" id="sonzaicheck"><span id="toc15">存在チェックの方法</span></h2>



<p>Googleドライブ上ではすべてのフォルダやファイルにユニークなIDが付与されていますので、同じファイル名や同じフォルダ名を作成することができます。GoogleApps Scriptでフォルダやファイルを作成するにはcreateFolderやcreateFileを使用しますが、そのままだと同名のフォルダやファイルが作成されてしまいます。同じフォルダ内に同名のフォルダやファイルが作成されない様にするには同名のフォルダやファイルが存在しているか判定して存在していないときのみcreateFolderやcreateFileで作成することが必要です。ここでは、同名のフォルダやファイルの存在チェックの方法について解説します。</p>



<h3 class="wp-block-heading"><span id="toc16">処理内容</span></h3>



<p>「写真フォルダ」の中に、「picture202306」と「picture202304」のフォルダがあります。ここに、「picture202304」「picture202305」「picture202306」「picture202307」という名前のフォルダを作成しますが、既に存在するフォルダは作成しないようにします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="537" height="302" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0361.png" alt="「写真」フォルダの構成(Googleドライブ)" class="wp-image-23000" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0361.png 537w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0361-300x169.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0361-500x281.png 500w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0361-120x68.png 120w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0361-160x90.png 160w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0361-320x180.png 320w" sizes="(max-width: 537px) 100vw, 537px" /></figure>



<p>つまり、既に存在する「picture202306」と「picture202304」のフォルダは作成せず、存在しない「picture202305」と「picture202307」のフォルダのみ作成します。</p>



<h3 class="wp-block-heading"><span id="toc17">スクリプトの作成</span></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="621" height="194" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0362.png" alt="存在チェックスクリプト(GAS)" class="wp-image-23001" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0362.png 621w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0362-300x94.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0362-500x156.png 500w" sizes="(max-width: 621px) 100vw, 621px" /></figure>



<pre class="wp-block-code"><code>function myFunction() {
  const folder = DriveApp.getFolderById("フォルダID");
  const newlist = &#91;"picture202304", "picture202305", "picture202306", "picture202307"]

  // 存在チェック
  for (let a = 0; a &lt; newlist.length; a++) {
    if (!folder.getFoldersByName(newlist&#91;a]).hasNext()) {
      // フォルダがなければ作成
      folder.createFolder(newlist&#91;a]);
      }
      // Logger.log(newlist&#91;a]);
  }
}</code></pre>



<h4 class="wp-block-heading">newlistの配列を読み込む</h4>



<p><strong>for (let a = 0; a&lt;newlist.length; a++) {</strong><br>　　　　// 読み込んだ時の処理<br><strong>}</strong></p>



<h4 class="wp-block-heading">読み込んだ時の処理</h4>



<p><strong>if (!folder.getFolderByName(newlist[a]).hasNext()) {</strong><br>　　　　// 存在しなかった時の処理<br><strong>}</strong></p>



<h4 class="wp-block-heading">存在しなかった時の処理</h4>



<p><strong>folder.createFolder(newlist[a]);</strong></p>



<p>[ スクリプトの解説 ]<br>getFoldersByNameメソッドもFolderIteratorを返しますので、イテレータの処理をしてフォルダ名を取得しています。newlistの配列に格納されているフォルダ名を次、次と取り出し同じフォルダ名があればtrueを返しますが、!(論理演算子)がついている為、falseを返します。つまり、同じフォルダ名が無かった時に、createFolderを実行します。</p>



<h3 class="wp-block-heading"><span id="toc18">スクリプトの検証</span></h3>



<p>folder.createFolder(newlist[a]);存在しなかった時の処理をコメントアウトして、logを表示して確認してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="622" height="374" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0363.png" alt="存在チェックスクリプトの検証(GAS)" class="wp-image-23002" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0363.png 622w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0363-300x180.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0363-500x301.png 500w" sizes="(max-width: 622px) 100vw, 622px" /></figure>



<p>存在しない「picture202305」と「picture202307」のフォルダのみが表示されました。</p>



<h3 class="wp-block-heading"><span id="toc19">スクリプトの実行</span></h3>



<p>スクリプトの検証ができましたので、コメントアウトを元に戻してスクリプトを実行します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="619" height="209" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0364.png" alt="存在チェックスクリプトの実行1" class="wp-image-23003" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0364.png 619w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0364-300x101.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0364-500x169.png 500w" sizes="(max-width: 619px) 100vw, 619px" /></figure>



<p>存在しない「picture202305」と「picture202307」のフォルダが作成されました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="623" height="434" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0365.png" alt="存在チェックスクリプトの実行2" class="wp-image-23004" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0365.png 623w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0365-300x209.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0365-500x348.png 500w" sizes="(max-width: 623px) 100vw, 623px" /></figure>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>GoogleAppsScriptの始め方(スクリプトの実行、トリガーの設定)</title>
		<link>https://gungii.com/gas02-info/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Tue, 04 Jul 2023 04:58:38 +0000</pubDate>
				<category><![CDATA[GAS]]></category>
		<category><![CDATA[ソフトウェア]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=22918</guid>

					<description><![CDATA[Google Apps Script(GAS)のスクリプトを作成しても、その実行をスクリプトエディタの画面から行うのであれば、それはいまいちです。今回はスプレッドシート上からGASのプログラムを実行する方法をご紹介します [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Google Apps Script(GAS)のスクリプトを作成しても、その実行をスクリプトエディタの画面から行うのであれば、それはいまいちです。今回はスプレッドシート上からGASのプログラムを実行する方法をご紹介します。GASの実行方法には次のような方法がありますので、ひとつずつご紹介します。</p>



<ul class="wp-block-list">
<li>スプレッドシート上にボタン(図形)を作成し、ボタンを押下してスクリプトを実行する。</li>



<li>スプレッドシートにオリジナルメニューを追加して、そのメニューで実行する</li>



<li>トリガーを利用して、自動起動を設定する</li>
</ul>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-12" checked><label class="toc-title" for="toc-checkbox-12">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">スクリプトの作成</a><ol><li><a href="#toc2" tabindex="0">組み込むスクリプト</a></li><li><a href="#toc3" tabindex="0">スクリプトの作成</a></li></ol></li><li><a href="#toc4" tabindex="0">ボタンを押下して実行</a><ol><li><a href="#toc5" tabindex="0">「シートの追加」ボタンの作成</a></li><li><a href="#toc6" tabindex="0">ボタンを押下して実行</a></li></ol></li><li><a href="#toc7" tabindex="0">オリジナルメニューで実行</a><ol><li><a href="#toc8" tabindex="0">オリジナルメニューの作成</a></li><li><a href="#toc9" tabindex="0">オリジナルメニューで実行</a></li></ol></li><li><a href="#toc10" tabindex="0">トリガーを設定して実行</a><ol><li><a href="#toc11" tabindex="0">トリガーの設定</a></li><li><a href="#toc12" tabindex="0">トリガーを設定して実行</a></li><li><a href="#toc13" tabindex="0">トリガーの削除</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">スクリプトの作成</span></h2>



<p>以前のブログ「【完全解説】googleスプレッドシートの使い方(Excel⇔スプレッドシート)」で、xlsxの「有給休暇管理表」をスプレッドシートに変換しましたが、元のxlsmの「有給休暇管理表」では「シートの追加」や「シート名の変更」は、VBAマクロで組んでいます。<br>そこで、今回は「シートの追加」や「シート名の変更」をGASで組み込んで、xlsmの「有給休暇管理表」と同等のスプレッドシートを作成して、VBAと同様にスクリプトを実行できる様にします。ここでは「シートの追加」スクリプトと、「シート名の変更」スクリプトを組み込んで、「ボタンを押下して実行する方法」と「オリジナルメニューで実行する方法」、「トリガーを設定して実行する方法」の3つの方法をご紹介します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="582" height="687" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0201.png" alt="有給休暇管理表(Excelとスプレッドシート)" class="wp-image-22920" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0201.png 582w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0201-300x354.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0201-500x590.png 500w" sizes="(max-width: 582px) 100vw, 582px" /></figure>



<p>こちらのスプレッドシートに、「シートの追加」スクリプトと、「シート名の変更」スクリプトを組み込みます。</p>



<h3 class="wp-block-heading"><span id="toc2">組み込むスクリプト</span></h3>



<h4 class="wp-block-heading">「シートの追加」スクリプト</h4>



<p>「シートの追加」ボタンを作成してボタンを押すと新しいシートが追加される様にします。現状「シートの追加」ボタンがない為、白紙のシートである「原紙」を手動でコピーするようにしていますが「シート追加」のボタンを設置してボタンを押下することでシートの追加ができるようにします。</p>



<h4 class="wp-block-heading">「シート名の自動入力」スクリプト</h4>



<p>社員番号・氏名が編集された時点で「社員番号+氏名」をシート名として自動的に書き込むようにします。</p>



<h3 class="wp-block-heading"><span id="toc3">スクリプトの作成</span></h3>



<p>まず、現状のスプレッドシートにVBAと同様に上記2つのスクリプトを組み込みます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="580" height="354" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0202.png" alt="スクリプトを組み込むスプレッドシート(GAS)" class="wp-image-22921" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0202.png 580w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0202-300x183.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0202-500x305.png 500w" sizes="(max-width: 580px) 100vw, 580px" /></figure>



<h4 class="wp-block-heading">「シートの追加」スクリプト</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="621" height="217" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0203.png" alt="「シートの追加」スクリプト(GAS)" class="wp-image-22922" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0203.png 621w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0203-300x105.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0203-500x175.png 500w" sizes="(max-width: 621px) 100vw, 621px" /></figure>



<p>コピーしたシートは表示に切り替えないと非表示のままとなります。また、シートを先頭に移動させる為にはアクティブにする必要があります。</p>



<h4 class="wp-block-heading">「シート名の自動入力」スクリプト</h4>



<p>入力された「社員番号」+「氏名」をシート名としてセットします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="623" height="202" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0204.png" alt="「シート名の自動入力」スクリプト(GAS)" class="wp-image-22923" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0204.png 623w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0204-300x97.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0204-500x162.png 500w" sizes="(max-width: 623px) 100vw, 623px" /></figure>



<h2 class="wp-block-heading"><span id="toc4">ボタンを押下して実行</span></h2>



<p>スプレッドシート上にボタンを作成して、そのボタンをクリックすることで処理を実行する方法について解説します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="580" height="666" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0211.png" alt="ボタンを追加したスプレッドシート(GAS)" class="wp-image-22924" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0211.png 580w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0211-300x344.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0211-500x574.png 500w" sizes="(max-width: 580px) 100vw, 580px" /></figure>



<p>注意:<br>「原紙」シートは非表示としています。「シートの追加」ボタンには、「シートの追加」スクリプトを割り当てています。</p>



<h3 class="wp-block-heading"><span id="toc5">「シートの追加」ボタンの作成</span></h3>



<p>「シートの追加」スクリプトは、ボタンを設置して、ボタンが押下されたらスクリプトを実行する様にしますので、「シートの追加」ボタンを作成します。</p>



<h4 class="wp-block-heading">「図形描画」をクリック</h4>



<p>スプレッドシートを開いて「挿入」から「図形描画」をクリックします。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0212.png" alt="「シートの追加」ボタンの作成1(GAS)" class="wp-image-22925" width="444" height="285" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0212.png 444w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0212-300x193.png 300w" sizes="(max-width: 444px) 100vw, 444px" /></figure>



<h4 class="wp-block-heading">図形の選択</h4>



<p>別ウインドウが表示されますのでお好きな図形を選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="570" height="323" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0213.png" alt="「シートの追加」ボタンの作成2(GAS)" class="wp-image-22926" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0213.png 570w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0213-300x170.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0213-500x283.png 500w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0213-120x68.png 120w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0213-160x90.png 160w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0213-320x180.png 320w" sizes="(max-width: 570px) 100vw, 570px" /></figure>



<h4 class="wp-block-heading">「保存して終了」をクリック</h4>



<p>「シートの追加」はテキストで入力します。良ければ「保存して終了」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="571" height="261" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0214.png" alt="「シートの追加」ボタンの作成3(GAS)" class="wp-image-22927" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0214.png 571w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0214-300x137.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0214-500x229.png 500w" sizes="(max-width: 571px) 100vw, 571px" /></figure>



<h4 class="wp-block-heading">ボタンの表示</h4>



<p>「保存して終了」をクリックすると、作成したボタンがGoogleスプレッドシート上に表示されます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="570" height="356" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0215.png" alt="「シートの追加」ボタンの作成4(GAS)" class="wp-image-22928" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0215.png 570w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0215-300x187.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0215-500x312.png 500w" sizes="(max-width: 570px) 100vw, 570px" /></figure>



<h4 class="wp-block-heading">ボタンの位置調整</h4>



<p>右クリックすると、手のマークとなりますので図形を掴んで、ボタンの位置を調整します。色や文字、形を変更したい場合は図形（ボタン）を右クリックして「︙」をクリックから「編集」を選択することで編集することが可能です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="580" height="201" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0216.png" alt="「シートの追加」ボタンの作成5(GAS)" class="wp-image-22929" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0216.png 580w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0216-300x104.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0216-500x173.png 500w" sizes="(max-width: 580px) 100vw, 580px" /></figure>



<h4 class="wp-block-heading">スクリプトの割り当て</h4>



<p>Googleスプレッドシート上にボタンが作成できましたら、ボタンに実行機能をもたせます。ここでは、「シートの追加」スクリプト(myFunct1)を割り当てます。</p>



<p>注意:<br>「シート名の自動入力」スクリプトはボタンでの実行にはなじまないので、トリガーの設定で実行する様にします。</p>



<h5 class="wp-block-heading">「︙」をクリック</h5>



<p>図形をクリックすると青枠で囲われて、図形の右上には縦に「︙」が表示されますので、「︙」をクリックして「スクリプトを割り当て」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="577" height="246" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0217.png" alt="スクリプトの割り当て1(GAS)" class="wp-image-22930" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0217.png 577w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0217-300x128.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0217-500x213.png 500w" sizes="(max-width: 577px) 100vw, 577px" /></figure>



<h5 class="wp-block-heading">関数名の入力</h5>



<p>別ウィンドウが表示されますので、自分で作成したfunctionの関数名を入力します。今回作成した関数は「myFunct1」と「myFunct2」ですが「シートの追加」ボタンに実行機能をもたせるスクリプトは「myFunct1」なので、ここでは「myFunct1」と入力します。<br>これでOKを押すと作成したボタンに実行機能をもたせることができます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="581" height="178" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0218.png" alt="スクリプトの割り当て2(GAS)" class="wp-image-22931" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0218.png 581w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0218-300x92.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0218-500x153.png 500w" sizes="(max-width: 581px) 100vw, 581px" /></figure>



<h3 class="wp-block-heading"><span id="toc6">ボタンを押下して実行</span></h3>



<p>「シートの追加」ボタンをクリックして、スクリプトが正しく実行されるかを確認します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="566" height="549" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0219.png" alt="ボタンを押下してスクリプトを実行(スプレッドシート)" class="wp-image-22932" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0219.png 566w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0219-300x291.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0219-500x485.png 500w" sizes="(max-width: 566px) 100vw, 566px" /></figure>



<p>正しく実行されました。が、コピー元の「原紙」シートに、「シートの追加」ボタンを設置していませんので、コピー元の「原紙」シートにも「シートの追加」ボタンを設置します。「原紙」シートにもボタンを設置して、完了です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="524" height="246" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0220.png" alt="「シートの追加」ボタンの作成(GAS)" class="wp-image-22933" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0220.png 524w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0220-300x141.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0220-500x235.png 500w" sizes="(max-width: 524px) 100vw, 524px" /></figure>



<h2 class="wp-block-heading"><span id="toc7">オリジナルメニューで実行</span></h2>



<p>次に、スプレッドシート上にメニューを作成して、そのメニューをクリックすることで処理を実行する方法について解説します。</p>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="605" height="573" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0221.png" alt="メニューを追加したスプレッドシート(GAS)" class="wp-image-22935" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0221.png 605w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0221-300x284.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0221-500x474.png 500w" sizes="(max-width: 605px) 100vw, 605px" /></figure>



<p>※メニューの名前は、「独自メニュー」としました。<br>メニューを選択すると、「シートの追加」と「シート名の設定」という2つのメニューが表示されますので、該当のメニューを選択して実行します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="215" height="88" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0222.png" alt="メニューの選択(スプレッドシート)" class="wp-image-22936"/></figure>



<h3 class="wp-block-heading"><span id="toc8">オリジナルメニューの作成</span></h3>



<h4 class="wp-block-heading">「メニュー追加」のスクリプト</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="617" height="450" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0223.png" alt="「メニュー追加」のスクリプト(GAS)" class="wp-image-22937" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0223.png 617w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0223-300x219.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0223-500x365.png 500w" sizes="(max-width: 617px) 100vw, 617px" /></figure>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box has-border-color has-orange-border-color"><div class="label-box-label block-box-label box-label"><span class="label-box-label-text block-box-label-text box-label-text">[ スクリプトの説明 ]</span></div><div class="label-box-content block-box-content box-content">
<p>onOpen() という関数は、スプレッドシートを開いた際に自動で呼び出される関数です。<br>var menuEntries = [ ]; でメニュー用の配列を定義し、menuEntries.push({ name: &#8220;シートの追加&#8221;, functionName: &#8220;myFunct1&#8221; }); で、配列にメニューを追加しています。<br>追加するメニューは、 {name: &#8220;サブメニュ名&#8221;, functionName, &#8220;呼び出す関数名&#8221;} という形式になっています。 メニューにセパレーター（メニューの区切りの線）を追加するには、menuEntries.push(null); のように null を追加することで可能です。最後に、ss.addMenu(&#8220;独自メニュー&#8221;, menuEntries); で、スプレッドシートに追加します。</p>
</div></div>



<p>※このスクリプトを実行すると、スプレッドシート上にメニューが追加されます。</p>



<h4 class="wp-block-heading">追加された「オリジナルメニュー」</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="598" height="251" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0224.png" alt="追加されたメニュー(スプレッドシート)" class="wp-image-22938" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0224.png 598w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0224-300x126.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0224-500x210.png 500w" sizes="(max-width: 598px) 100vw, 598px" /></figure>



<h3 class="wp-block-heading"><span id="toc9">オリジナルメニューで実行</span></h3>



<p>オリジナルメニューで「シートの追加」スクリプトを実行します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="611" height="542" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0225.png" alt="スクリプトの実行(スプレッドシート)" class="wp-image-22939" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0225.png 611w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0225-300x266.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0225-500x444.png 500w" sizes="(max-width: 611px) 100vw, 611px" /></figure>



<p>シートが追加されました。</p>



<h2 class="wp-block-heading"><span id="toc10">トリガーを設定して実行</span></h2>



<h3 class="wp-block-heading"><span id="toc11">トリガーの設定</span></h3>



<p>GASのトリガーとは、特定条件(きっかけ)でGASスクリプトを実行させる仕組みのことです。「スプレッドシートを編集する」や「特定の時間になる」等、スクリプト実行のきっかけとなるイベントをあらかじめ指定しておくことで、処理を自動化・効率化することができます。GASのトリガーには大きく分けて、Simple triggers(シンプルトリガー)とInstallabletriggers(インストーラブルトリガー)が存在します。<br>「Simple triggers」はGASのスクリプト上でトリガーを設定する方法で、<br>「Installable triggers」はスクリプトエディターで設定する方法です。</p>



<p>Installable triggersのほうが簡単で使い勝手が良いですが、Simple triggersはスクリプト上で設定できることで入力された値や条件によってトリガーを変更するなど、柔軟なトリガー設定が可能です。<br>ここでは、インストーラブルトリガーについて解説します。</p>



<h4 class="wp-block-heading">「トリガー」をクリック</h4>



<p>エディタのスクリプトファイル横にあるタブのうち、時計マークをクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="405" height="217" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0231.png" alt="トリガーの設定1(GAS)" class="wp-image-22940" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0231.png 405w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0231-300x161.png 300w" sizes="(max-width: 405px) 100vw, 405px" /></figure>



<h4 class="wp-block-heading">「+トリガーを追加」をクリック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="477" height="339" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0232.png" alt="トリガーの設定2(GAS)" class="wp-image-22941" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0232.png 477w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0232-300x213.png 300w" sizes="(max-width: 477px) 100vw, 477px" /></figure>



<h4 class="wp-block-heading">トリガーの設定</h4>



<p>「実行する関数」と「イベントのソース」を設定します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="521" height="413" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0233.png" alt="トリガーの設定3(GAS)" class="wp-image-22942" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0233.png 521w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0233-300x238.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0233-500x396.png 500w" sizes="(max-width: 521px) 100vw, 521px" /></figure>



<h5 class="wp-block-heading">実行する関数</h5>



<p>あらかじめ作成した関数名が表示されます。(複数ある場合は複数表示される)<br>ここでは、「シート名の自動入力」スクリプトを実行する関数(myFunc2)を選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="243" height="128" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0234.png" alt="トリガーの設定4(GAS)" class="wp-image-22943"/></figure>



<h5 class="wp-block-heading">実行するデプロイ</h5>



<p>実行対象となるバージョンを選択できます。「Head」が最新のデプロイで、バージョンXXは過去のデプロイとなります。現在、選択肢はありませんので、そのままOKです。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="243" height="94" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0235.png" alt="トリガーの設定5(GAS)" class="wp-image-22944"/></figure>



<h5 class="wp-block-heading">イベントのソース</h5>



<p>GASをどのタイミングで実行するかを設定します。ここでは、スプレッドシートからを選択します。</p>



<ul class="wp-block-list">
<li>時間主導型：特定の時間単位(日時、週次、月次など)で実行します。</li>



<li>スプレッドシートから：<br>スプレッドシート、ドキュメント、フォーム等の起動や編集、送信時に実行します。</li>



<li>カレンダーから：カレンダー更新時に実行します。</li>
</ul>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="244" height="180" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0236.png" alt="トリガーの設定6(GAS)" class="wp-image-22945"/></figure>



<h5 class="wp-block-heading">イベントの種類</h5>



<p>関数(myFunct2)は、社員番号、氏名を編集した時に実行したいので、「編集時」を選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="244" height="219" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0237.png" alt="トリガーの設定7(GAS)" class="wp-image-22946"/></figure>



<h4 class="wp-block-heading">「保存」をクリック</h4>



<p>設定が完了しましたら、「保存」をクリックします。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0238.png" alt="トリガーの設定8(GAS)" class="wp-image-22947" width="521" height="411" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0238.png 521w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0238-300x237.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0238-500x394.png 500w" sizes="(max-width: 521px) 100vw, 521px" /></figure>



<h4 class="wp-block-heading">「トリガーの追加」の完了</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="519" height="263" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0239.png" alt="トリガーの設定9(GAS)" class="wp-image-22948" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0239.png 519w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0239-300x152.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0239-500x253.png 500w" sizes="(max-width: 519px) 100vw, 519px" /></figure>



<h3 class="wp-block-heading"><span id="toc12">トリガーを設定して実行</span></h3>



<p>関数(myFunct2)は、社員番号、氏名を入力すると、シート名が「社員番号+氏名」に書き換わるというスクリプトです。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="497" height="251" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0240.png" alt="トリガーの実行1(GAS)" class="wp-image-22949" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0240.png 497w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0240-300x152.png 300w" sizes="(max-width: 497px) 100vw, 497px" /></figure>



<p>社員番号、氏名を入力してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="499" height="524" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0241.png" alt="トリガーの実行2(GAS)" class="wp-image-22950" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0241.png 499w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0241-300x315.png 300w" sizes="(max-width: 499px) 100vw, 499px" /></figure>



<p>「原紙のコピー」のシートの方も入力してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="475" height="241" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0242.png" alt="トリガーの実行3(GAS)" class="wp-image-22952" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0242.png 475w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0242-300x152.png 300w" sizes="(max-width: 475px) 100vw, 475px" /></figure>



<h3 class="wp-block-heading"><span id="toc13">トリガーの削除</span></h3>



<p>設定したトリガーを削除する方法をご紹介しておきます。</p>



<h4 class="wp-block-heading">「トリガー」をクリック</h4>



<p>スクリプトエディターの画面で左のメニューから「トリガー」を選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="524" height="202" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0243.png" alt="トリガーの削除1(GAS)" class="wp-image-22951" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0243.png 524w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0243-300x116.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0243-500x193.png 500w" sizes="(max-width: 524px) 100vw, 524px" /></figure>



<h4 class="wp-block-heading">「︙」をクリック</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="524" height="233" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0244.png" alt="トリガーの削除2(GAS)" class="wp-image-22953" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0244.png 524w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0244-300x133.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0244-500x222.png 500w" sizes="(max-width: 524px) 100vw, 524px" /></figure>



<h4 class="wp-block-heading">「トリガーを削除」をクリック</h4>



<p>表示されたメニューから「トリガーを削除」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="523" height="262" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0245.png" alt="トリガーの削除3(GAS)" class="wp-image-22954" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0245.png 523w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0245-300x150.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0245-500x250.png 500w" sizes="(max-width: 523px) 100vw, 523px" /></figure>



<h4 class="wp-block-heading">削除の確認</h4>



<p>「トリガーの削除」をクリックすると、再度確認メッセージが表示されますので、「完全に削除」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="523" height="260" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0246.png" alt="トリガーの削除4(GAS)" class="wp-image-22955" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0246.png 523w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0246-300x149.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0246-500x249.png 500w" sizes="(max-width: 523px) 100vw, 523px" /></figure>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>GoogleAppsScriptの始め方(基本的な使い方)</title>
		<link>https://gungii.com/gas01-info/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Sat, 01 Jul 2023 05:07:47 +0000</pubDate>
				<category><![CDATA[GAS]]></category>
		<category><![CDATA[ソフトウェア]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=22841</guid>

					<description><![CDATA[GoogleAppscript(GAS)とは、Googleが開発・提供しているプログラミング言語です。JavaScriptというWebブラウザ上で動作するプログラミング言語をベースに作成されています。「GASを覚えたいけ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>GoogleAppscript(GAS)とは、Googleが開発・提供しているプログラミング言語です。JavaScriptというWebブラウザ上で動作するプログラミング言語をベースに作成されています。<br>「GASを覚えたいけど、どこから始めたら良いのかわからない」<br>「ExcelのマクロをGASで作り変えたいけど、実際に動かせるのだろうか?」<br>「スプレッドシートで作った管理表をWebに公開してスタッフが見れるようにしたい」<br>このようにGASに興味はあっても、実際に何から始めたら良いのか不安で、一歩を踏み出せない方もいるのではないでしょうか。自分で調べようにも、何を調べれば良いのか?がわからない。何がわからないか?がわからない自分がそこにあるのです。ポイントさえ掴めば、現在はネットで調べることができます。(今、話題のChatGPTでも調べられます)。<br>本記事では、GASを利用するに当たって理解しておくべきポイントや基本的なスプレッドシートの扱い方、スクリプト(プログラム)作成方法をでできるだけ、詳細に紹介しています。GASをどうやって勉強すれば良いかもわかりますので、GASが初めての方でもスムーズに取り掛かることができます。GASに興味がある方や業務の効率化を考えている方にも、有益な内容となっています。ぜひこの記事を読んで、GASの利用を検討してみてください。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box has-border-color has-luminous-vivid-orange-border-color"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">GASの特徴</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Gmailアカウントさえあれば誰でも無料で使えます。<br>GASは、Gmailアカウントさえあれば誰でも無料で始められるのが特徴です。</li>



<li>Googleの関連サービスと連携できる<br>GmailやGoogleスプレッドシートなど、Googleが提供する各種サービスツールとの連携が容易で、各種サービスの効率化や作業の自動化をGASで開発して取り入れることができます。Googleドライブ、Googleドキュメント、スプレッドシート、Googleカレンダー、Googleマップ、Gメール等</li>



<li>開発環境はWebブラウザで動作するためセットアップが不要<br>GASの開発環境はGoogleのWebブラウザベースで動作し、開発環境のインストール等のセットアップが必要ありません。スクリプトの実行もGoogleのサーバー上で行われるため、自身のパソコンを起動する必要もありません。</li>



<li>JavaScriptをベースに作られている<br>GAS専用の関数はあるものの、言語の基本はWebアプリケーションにもよく用いられる言語であるJavaScriptをベースに作られている為、覚えておいて損はありません。</li>
</ul>
</div></div>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-14" checked><label class="toc-title" for="toc-checkbox-14">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">スクリプトエディターの使い方</a><ol><li><a href="#toc2" tabindex="0">スクリプトの種類</a></li><li><a href="#toc3" tabindex="0">エディターの画面構成</a></li><li><a href="#toc4" tabindex="0">エディターの使い方</a></li><li><a href="#toc5" tabindex="0">コメントアウトの方法</a></li></ol></li><li><a href="#toc6" tabindex="0">スプレッドシートの構成</a><ol><li><a href="#toc7" tabindex="0">スプレッドシートの構成</a></li><li><a href="#toc8" tabindex="0">スクリプトの構成</a></li></ol></li><li><a href="#toc9" tabindex="0">スクリプトを書く</a><ol><li><a href="#toc10" tabindex="0">A1に値を入れる</a></li><li><a href="#toc11" tabindex="0">A1セルの値をB1へ</a></li><li><a href="#toc12" tabindex="0">承認の方法</a></li></ol></li><li><a href="#toc13" tabindex="0">スプレッドシートの操作</a><ol><li><a href="#toc14" tabindex="0">スプレッドシートの取得</a></li><li><a href="#toc15" tabindex="0">スプレッドシートのコピー</a></li></ol></li><li><a href="#toc16" tabindex="0">シートの操作</a><ol><li><a href="#toc17" tabindex="0">シートの取得</a></li><li><a href="#toc18" tabindex="0">シートのコピー</a></li><li><a href="#toc19" tabindex="0">シート名をセットする。</a></li><li><a href="#toc20" tabindex="0">シートをクリアする。</a></li></ol></li><li><a href="#toc21" tabindex="0">セルの操作</a><ol><li><a href="#toc22" tabindex="0">セルを指定して取得する。</a></li><li><a href="#toc23" tabindex="0">セル範囲を自動で取得する</a></li><li><a href="#toc24" tabindex="0">セル値の取得・セット</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">スクリプトエディターの使い方</span></h2>



<h3 class="wp-block-heading"><span id="toc2">スクリプトの種類</span></h3>



<p>GASには、スプレッドシートやフォームに紐付くコンテナバインド型「Container Bound Script」と、独立したスタンドアロン型「Standalone Script」(ドライブ上に単独で存在するもの)との2種類の開発方式があります。コンテナバインド型は、GoogleスプレッドシートやGoogleドキュメント、外部サービスなどと連携して動作するスクリプトのことです。GASはExcelやWordで使えるVBAと同じように、スプレッドシートなどのドキュメントと紐付けることが可能です。スタンドアロン型は、単体で動作するスクリプトのことで、GoogleスプレッドシートやGoogleフォームなど、Google関連サービスと連携する必要がない場合に使用します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="462" height="339" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0101.png" alt="コンテナバインドとスタンドアロン(GAS)" class="wp-image-22843" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0101.png 462w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0101-300x220.png 300w" sizes="(max-width: 462px) 100vw, 462px" /></figure>



<h4 class="wp-block-heading">コンテナバインド型</h4>



<p>スプレッドシートから「スクリプトエディタ」を選択すると、自動的にContainer BoundScriptプロジェクトが作成されます。</p>



<h5 class="wp-block-heading">コンテナバインド型のGASエディターの開き方</h5>



<p>コンテナバインド型のGASでスクリプトエディタを開く場合は紐づくサービスのメニューからスクリプトエディタを開きます。各アプリ(GoogleAppsScript)の拡張機能からAppsScriptをクリックすると、エディターを開くことができます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="591" height="177" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0102.png" alt="エディターの開き方(GASコンテナバインド)" class="wp-image-22844" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0102.png 591w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0102-300x90.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0102-500x150.png 500w" sizes="(max-width: 591px) 100vw, 591px" /></figure>



<p>[ その他のサービス ]</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="333" height="185" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0103.png" alt="エディターの開き方(Googleドキュメント、スライド)" class="wp-image-22845" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0103.png 333w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0103-300x167.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0103-120x68.png 120w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0103-160x90.png 160w" sizes="(max-width: 333px) 100vw, 333px" /></figure>



<h5 class="wp-block-heading">コンテナバインド型のメリット</h5>



<ul class="wp-block-list">
<li>コンテナバインドでのみ利用可能なコードがあります。<br>(アラートを表示したり、HTMLを表示するコードetc)</li>



<li>Googleスプレッドシートから利用ができるため、手軽に始められます。</li>



<li>IDなどを指定しなくても参照が可能なクラスが準備されています。</li>



<li>スクリプトの実行が簡単<br>「Googleスプレッドシート」などは図形などにスクリプトを割り当てることによりスクリプトの実行が簡単にできます。</li>
</ul>



<h5 class="wp-block-heading">コンテナバインド型のデメリット</h5>



<ul class="wp-block-list">
<li>扱っているGASのスクリプトの数が増えると管理が大変。</li>



<li>Googleドライブ上で確認できない。<br>Googleドライブ上にスクリプトファイルは表示されないため、スクリプトが設定されているかどうか分からない。<br>注意:GASのホーム(https://script.google.com/home)で確認できます。</li>
</ul>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="544" height="217" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0104.png" alt="GASホームに表示されたGASファイル" class="wp-image-22846" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0104.png 544w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0104-300x120.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0104-500x199.png 500w" sizes="(max-width: 544px) 100vw, 544px" /></figure>



<h4 class="wp-block-heading">スタンドアロン型</h4>



<h5 class="wp-block-heading">スタンドアロン型のGASエディタの開き方</h5>



<p>GASのスタンドアロンスクリプトは、Googleドライブから新規ファイルとして開くことができます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="603" height="204" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0105.png" alt="エディターの開き方(GASスタンドアロン)" class="wp-image-22847" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0105.png 603w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0105-300x101.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0105-500x169.png 500w" sizes="(max-width: 603px) 100vw, 603px" /></figure>



<h5 class="wp-block-heading">スタンドアロン型のメリット</h5>



<ul class="wp-block-list">
<li>スタンドアロン型のGASファイルはGoogleドライブに表示されます。<br>Googleドライブで表示される為、管理しやすい</li>



<li>スクリプトを隠すことができます。<br>スプレッドシートなどに紐付かないため、スプレッドシート利用者に対し、スクリプトを秘匿することが可能です。</li>
</ul>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="554" height="250" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0106.png" alt="Googleドライブに表示されたGASファイル" class="wp-image-22848" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0106.png 554w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0106-300x135.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0106-500x226.png 500w" sizes="(max-width: 554px) 100vw, 554px" /></figure>



<h5 class="wp-block-heading">スタンドアロン型のデメリット</h5>



<ul class="wp-block-list">
<li>コンテナバインドでできるコードがスタンドアロンではできないこと。</li>



<li>スプレッドシートから実行できない。<br>紐付けされていないため「Googleスプレッドシート」などからスクリプトの実行ができません。</li>



<li>「Googleスプレッドシート」などを操作する場合はIDが必要となります。</li>
</ul>



<p>機能的な面で言えば、コンテナバインド型の方がすべての機能がありますが、管理のしやすさからはスタンドアロン型となります。Google Apps Scriptの利用ケースを考慮し、コンテナバインド型でしかできない場合はコンテナバインド型を選択、そうでなければ、スタンドアロン型を選択するのがオススメです。(初めての場合は、VBAと同じコンテナバインド型の方が入りやすいでしょう。)</p>



<h3 class="wp-block-heading"><span id="toc3">エディターの画面構成</span></h3>



<p>スクリプトエディターとは、コードを記述したり、管理する場所のことです。エディターは、プロジェクトとファイルで構成されます。GASではスクリプト(プログラム)を「プロジェクト」という単位で作成していきます。プロジェクトの中にはいくつかの「ファイル」を作ることができます。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0107.png" alt="エディターの画面構成(GAS)" class="wp-image-22849" width="549" height="224" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0107.png 547w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0107-300x122.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0107-500x204.png 500w" sizes="(max-width: 549px) 100vw, 549px" /></figure>



<h4 class="wp-block-heading">プロジェクト名の変更</h4>



<p>プロジェクト名をクリックすると以下のような画面が表示されますので、プロジェクトタイトルを入力して「名前を変更」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="458" height="255" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0108.png" alt="プロジェクト名の変更(GAS)" class="wp-image-22850" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0108.png 458w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0108-300x167.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0108-120x68.png 120w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0108-160x90.png 160w" sizes="(max-width: 458px) 100vw, 458px" /></figure>



<h4 class="wp-block-heading">ファイル名の変更</h4>



<p>「︙」をクリックして、「名前を変更」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="461" height="392" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0109.png" alt="ファイル名の変更(GAS)" class="wp-image-22851" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0109.png 461w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0109-300x255.png 300w" sizes="(max-width: 461px) 100vw, 461px" /></figure>



<h4 class="wp-block-heading">関数名(myFunction)の変更</h4>



<p>同一<strong>プロジェクト内では関数名はユニーク</strong>とします。例えばコード1.gs、コード2.gs等と別ファイルとしていても同じ関数名(例えばmyFunction)であれば、すべてのmyFunctionが実行されます。<br>例:<br>関数名は同じ「myFunction」となっていますので、シートの追加.gsのmyFunctionも、シート名の設定.gsのmyFunctionも実行されてしまいます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="551" height="513" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0110.png" alt="関数名の変更(GAS)" class="wp-image-22852" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0110.png 551w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0110-300x279.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0110-500x466.png 500w" sizes="(max-width: 551px) 100vw, 551px" /></figure>



<h3 class="wp-block-heading"><span id="toc4">エディターの使い方</span></h3>



<p>ここでは、コンテナバインド型スクリプトで解説をします。</p>



<h4 class="wp-block-heading">Google Driveから新規のスプレッドシートを開く</h4>



<h5 class="wp-block-heading">「+新規」ボタンをクリック</h5>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="526" height="262" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0111.png" alt="新規ボタン(Googleドライブ)" class="wp-image-22853" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0111.png 526w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0111-300x149.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0111-500x249.png 500w" sizes="(max-width: 526px) 100vw, 526px" /></figure>



<h5 class="wp-block-heading">「空白のスプレッドシート」をクリック</h5>



<p>「Googleスプレッドシートから「空白のスプレッドシート」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="514" height="260" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0112.png" alt="スプレッドシートの作成(Googleドライブ)" class="wp-image-22854" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0112.png 514w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0112-300x152.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0112-500x253.png 500w" sizes="(max-width: 514px) 100vw, 514px" /></figure>



<h4 class="wp-block-heading">GoogleスプレッドシートからGASを開く</h4>



<p>スプレッドシートを開いて「拡張機能」タブから「AppsScript」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="591" height="177" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0113.png" alt="AppsScriptの選択(スプレッドシート)" class="wp-image-22855" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0113.png 591w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0113-300x90.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0113-500x150.png 500w" sizes="(max-width: 591px) 100vw, 591px" /></figure>



<h4 class="wp-block-heading">スクリプトの作成・保存</h4>



<h5 class="wp-block-heading">コードを記述する</h5>



<p>スクリプトエディターが開きますので、ここにスクリプトを書いていきます。()と{の間は、ここでは半角空白を入れていますが、なくても構いません、見易さの問題です。最後の}は忘れずに、先に書いておきましょう。</p>



<ul class="wp-block-list">
<li>ステートメントの最後にはセミコロン(;)を記述する</li>



<li>命令は大文字・小文字が厳密に区別されています</li>
</ul>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="588" height="176" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0114.png" alt="スクリプトの作成1(コード.gs)" class="wp-image-22856" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0114.png 588w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0114-300x90.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0114-500x150.png 500w" sizes="(max-width: 588px) 100vw, 588px" /></figure>



<p>画面上部にある「無題のプロジェクト」というのは、プロジェクトのタイトルです。こちらは自由に書き換えて構いません。 この場合は、例えば「スプレッドシート作成」などと設定しましょう。「myFunction」は、関数名です。実行する内容に合わせて書き換えるとプロジェクトが大きくなったときにわかりやすいでしょう。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="569" height="171" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0115.png" alt="スクリプトの作成2(コード.gs)" class="wp-image-22857" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0115.png 569w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0115-300x90.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0115-500x150.png 500w" sizes="(max-width: 569px) 100vw, 569px" /></figure>



<p>ここでは、Logger.log(“Hello! GAS!”);と書きます。Logger.log()はGASでログ（履歴のようなもの）を表示するために使用する関数です。</p>



<h5 class="wp-block-heading">書いたコードを保存する。</h5>



<p>「保存」ボタンをクリックするか又は、[Ctrl + S]で保存出来ます。「コード.gs」に付いているオレンジの印が消えたら「保存完了」。○コード.gsとして○がついている時は、保存されていないことを意味します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="567" height="175" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0116.png" alt="スクリプトの保存(コード.gs)" class="wp-image-22858" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0116.png 567w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0116-300x93.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0116-500x154.png 500w" sizes="(max-width: 567px) 100vw, 567px" /></figure>



<p>保存すると○は消えます。スプレッドシートやドキュメントと異なり、GASのスクリプトは自動保存ではありません。</p>



<h4 class="wp-block-heading">コードを実行する</h4>



<p>「実行」ボタンをクリックをクリックするか又は、[Ctrl+R]で実行できます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="567" height="228" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0117.png" alt="スクリプトの実行(コード.gs)" class="wp-image-22859" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0117.png 567w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0117-300x121.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0117-500x201.png 500w" sizes="(max-width: 567px) 100vw, 567px" /></figure>



<p>上のようなログが表示されたら成功です。<br>留意:GASのスクリプトは関数単位で実行します。<br>ファイルに複数の関数を入力している時には、目的の関数を選択しておく必要がありますので、ご注意下さい。プルダウンで実行したい関数を選択します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="569" height="194" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0118.png" alt="関数の選択(gas)" class="wp-image-22915" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0118.png 569w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0118-300x102.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0118-500x170.png 500w" sizes="(max-width: 569px) 100vw, 569px" /></figure>



<h3 class="wp-block-heading"><span id="toc5">コメントアウトの方法</span></h3>



<p>コメントアウトのやり方は2パターンあります。</p>



<h4 class="wp-block-heading">先頭に//を付ける(各行)</h4>



<p>コメントアウトしたい行のどこでもよいのでカーソルを位置づけて、CTRL+/を押します。<br>※再度CRTL+/で解除されます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="582" height="406" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0119.png" alt="GASコメントアウトの方法1(各行)" class="wp-image-22862" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0119.png 582w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0119-300x209.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0119-500x349.png 500w" sizes="(max-width: 582px) 100vw, 582px" /></figure>



<h4 class="wp-block-heading">「/*<em>と</em>/」で囲む(複数行)</h4>



<p>ショートカットはないので、手入力します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="581" height="184" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0120.png" alt="GASコメントアウトの方法2(複数行)" class="wp-image-22863" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0120.png 581w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0120-300x95.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0120-500x158.png 500w" sizes="(max-width: 581px) 100vw, 581px" /></figure>



<h2 class="wp-block-heading"><span id="toc6">スプレッドシートの構成</span></h2>



<h3 class="wp-block-heading"><span id="toc7">スプレッドシートの構成</span></h3>



<p>スプレッドシートは、4つクラスで構成されています。GASにおいて、スプレッドシートを操作するためのクラスを提供するのがSpreadsheetサービスです。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="579" height="464" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0121.png" alt="スプレッドシートの構成" class="wp-image-22864" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0121.png 579w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0121-300x240.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0121-500x401.png 500w" sizes="(max-width: 579px) 100vw, 579px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="494" height="262" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0122.png" alt="スプレッドシートの構成(簡略図)" class="wp-image-22865" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0122.png 494w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0122-300x159.png 300w" sizes="(max-width: 494px) 100vw, 494px" /></figure>



<p>SpreadsheetAppクラスから、Spreadsheetクラス→Sheetクラス→Rangeクラスと配下になるに従って枠が限定されている階層構造となっています。クラスは、「便利な関数(function)をグループ分けする箱」で、クラスに所属する関数をメソッドと捉えます</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box has-border-color has-orange-border-color"><div class="label-box-label block-box-label box-label fab-edit"><span class="label-box-label-text block-box-label-text box-label-text">クラス</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>[ SpreadsheetAppクラス ]<br>Spreadsheetサービスの最上位に位置するクラスがSpreadsheetAppクラスです。スプレッドシートというアプリケーションとなり、スプレッドシートファイルのデータを管理するクラスです。</li>



<li>[ Spreadsheetクラス ]<br>Excelで言えば「ブック」でありスプレッドシートのデータ(シート、スプレッドシートの名前、アクセス権限等)を管理するクラスです。例えば、スプレッドシートのファイル名の変更、シートの作成、取得、削除等ができます。</li>



<li>[ Sheetクラス ]<br>Excelでもシートとなり、シートのデータ(シート名、セル等)を管理するクラスです。例えば、シート名の変更、行の追加・削除、選択した範囲のセルの取得などができます。</li>



<li>[ Rangeクラス ]<br>選択した範囲のセルのデータを管理するクラスです。例えば、セルの値を取得・変更することができます。</li>
</ul>
</div></div>



<h3 class="wp-block-heading"><span id="toc8">スクリプトの構成</span></h3>



<p>プログラムは、基本的には3つの要素から成り立っています。簡単に説明すると、操作対象を表す「オブジェクト」、”動き”を表す「メソッド」、&#8221;状態&#8221;を表す「プロパティ」の3要素から成り立っています。オブジェクトはプロパティで管理(オブジェクトの内容や詳細、属性)されていて、プロパティの値に数値や文字列が入っているものがプロパティ、プロパティの値に関数が入っているものがメソッドとなります。</p>



<h4 class="wp-block-heading">オブジェクト</h4>



<p>プログラムでは、「何かをどうする」と言った形で命令を書きます。この「何を」がオブジェクトになります。GASではスプレッドシートをはじめ各サービスの操作対象とするモノを「オブジェクト」と言い、次のようなオブジェクトが用意されています。</p>



<ul class="wp-block-list">
<li>アプリケーション:SpreadsheetAppオブジェクト</li>



<li>スプレッドシート：Spreadsheetオブジェクト</li>



<li>シート：Sheetオブジェクト</li>



<li>セル範囲：Rangeオブジェクト</li>
</ul>



<p>そしてオブジェクトはスプレッドシートのアプリケーション→スプレッドシート(ブック)→シート→セルという階層構造になっています。また、これらを操作するために、メソッドとよばれるたくさんの命令が用意されています。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="619" height="226" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0123.png" alt="社員名簿(スプレッドシート)" class="wp-image-22866" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0123.png 619w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0123-300x110.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0123-500x183.png 500w" sizes="(max-width: 619px) 100vw, 619px" /></figure>



<p>[ 処理内容 ]<br>例えば、スプレッドシート「社員名簿」のシート「ハッピイ1号館」のD3セルの値を取得するという処理は、次のようになります。</p>



<ol class="wp-block-list">
<li>スプレッドシート「社員名簿」を、Spreadsheetオブジェクトとして取得する</li>



<li>そのSpreadsheetオブジェクトの配下にあるシート「ハッピイ1号館」を、Sheetオブジェクトとして取得する</li>



<li>そのSheetオブジェクトの配下にあるD3セルを、Rangeオブジェクトとして取得する</li>



<li>そのRangeオブジェクトの値を取得する</li>
</ol>



<h4 class="wp-block-heading">メソッド</h4>



<p>メソッドはオブジェクトに対する命令です。getActiveScriptSheet、getSheetByName、getActiveSheet、getRange、setValue等はメソッドとなります。VBAではプロパティになります。</p>



<ol class="wp-block-list">
<li>getActiveScriptSheetを実行して、アクティブなスプレッドシートを受け取り、</li>



<li>getSheetByNameを実行して、シート(社員名簿)を受け取り、</li>



<li>.getRangeを実行して、セル(D3)を受け取り、</li>



<li>.getValueを実行して、セルの値(54)を取得します。</li>
</ol>



<h2 class="wp-block-heading"><span id="toc9">スクリプトを書く</span></h2>



<p>それでは、実際にスクリプトを書いてみます。スプレッドシートのシート1のA1セルに「Hello! GAS!」という文字を書き込んでみます。</p>



<h3 class="wp-block-heading"><span id="toc10">A1に値を入れる</span></h3>



<h4 class="wp-block-heading">スプレッドシートの作成</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="584" height="192" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0131.png" alt="スプレッドシートの作成(GAS)" class="wp-image-22867" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0131.png 584w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0131-300x99.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0131-500x164.png 500w" sizes="(max-width: 584px) 100vw, 584px" /></figure>



<p>現在、A1セルは空白です。ここに「Hello!! GAS!」という文字を書き込みます。A1セルに「Hello! GAS!」という文字を書き込むスクリプトを入力してみます。</p>



<h4 class="wp-block-heading">スクリプトの作成</h4>



<p>「拡張機能」タブから「Apps Script」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="586" height="443" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0132.png" alt="スクリプトの作成手順1(例1)" class="wp-image-22868" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0132.png 586w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0132-300x227.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0132-500x378.png 500w" sizes="(max-width: 586px) 100vw, 586px" /></figure>



<p>A1セルを特定する為にSpreadsheetAppクラスから、Spreadsheetクラス→Sheetクラス→Rangeクラスと階層を特定する必要があります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="588" height="183" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0133.png" alt="スクリプトの作成手順2(例1)" class="wp-image-22869" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0133.png 588w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0133-300x93.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0133-500x156.png 500w" sizes="(max-width: 588px) 100vw, 588px" /></figure>



<h5 class="wp-block-heading">SpreadsheetApp.getActiveSpreadsheet();</h5>



<p>SpreadsheetAppは、スプレッドシート全体を意味するトップレベルのオブジェクトです。<br>constは、変数宣言で、varとletとは異なり再代入／再宣言のできない宣言方法です。</p>



<p>getActiveSpreadsheet()メソッドは、アクティブなスプレッドシートを取得します。つまりSpreadsheetApp.getActiveSpreadsheet()は、「スプレッドシート全体の中から、アクティブなスプレッドシートを取得せよ」という命令です。その結果(戻り値)を、変数「SS」に格納していますので、変数「SS」には、「アクティブなスプレッドシート(Spreadsheetオブジェクト)」が格納されているのです。</p>



<h5 class="wp-block-heading">ss.getSheetByName(&#8220;シート1&#8221;);</h5>



<p>Spreadsheetオブジェクトの配下にあるシート(&#8220;シート&#8221;)を、getSheetByNameメソッドを実行して、Sheetオブジェクトとして取得します。</p>



<h5 class="wp-block-heading">sheet.getrange(&#8220;A1&#8221;);</h5>



<p>Sheetオブジェクトの配下にあるA1セルを、getRangeメソッドを実行して、Rangeオブジェクトとして取得します。</p>



<h5 class="wp-block-heading">range.setValue(&#8220;HELLO! GAS!&#8221;);</h5>



<p>A1セルに&#8221;Hello! GAS!&#8221;という文字をセット(書き込みます)します。</p>



<h4 class="wp-block-heading">スクリプトの実行</h4>



<p>スクリプトができましたので、実行してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="541" height="208" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0134.png" alt="スクリプトの実行手順1(例1)" class="wp-image-22870" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0134.png 541w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0134-300x115.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0134-500x192.png 500w" sizes="(max-width: 541px) 100vw, 541px" /></figure>



<p>注意:<br>スクリプトを初回実行するとき次のような承認画面が表示された場合は承認作業を行ってください。<br>手順は<code><a href="#syonin">こちら</a></code>。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="389" height="122" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0135.png" alt="スクリプトの実行承認(GAS)" class="wp-image-22871" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0135.png 389w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0135-300x94.png 300w" sizes="(max-width: 389px) 100vw, 389px" /></figure>



<h4 class="wp-block-heading">実行結果</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="541" height="407" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0136.png" alt="スクリプトの実行結果(例1)" class="wp-image-22872" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0136.png 541w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0136-300x226.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0136-500x376.png 500w" sizes="(max-width: 541px) 100vw, 541px" /></figure>



<h3 class="wp-block-heading"><span id="toc11">A1セルの値をB1へ</span></h3>



<p>次に、A1の値を取得して、B1に書き込む場合のスクリプトの書き方をやってみます。現在A1セルには、「こんにちは!!」という文字が書き込まれています。この文字を取得して、B1セルに書き込みます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="580" height="180" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0137.png" alt="スクリプトの作成手順1(例2)" class="wp-image-22873" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0137.png 580w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0137-300x93.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0137-500x155.png 500w" sizes="(max-width: 580px) 100vw, 580px" /></figure>



<h4 class="wp-block-heading">スクリプトの作成</h4>



<p>まずは、どこに値をいれるのか?でgetRange(&#8220;B1&#8221;)を指定して、setValue()で値をsetします。その値は、どこの値か?でgetRange(&#8220;A1&#8221;)を指定して、getします。</p>



<h4 class="wp-block-heading">実行結果</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="586" height="436" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0138.png" alt="スクリプトの実行結果(例2)" class="wp-image-22874" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0138.png 586w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0138-300x223.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0138-500x372.png 500w" sizes="(max-width: 586px) 100vw, 586px" /></figure>



<h3 class="wp-block-heading" id="syonin"><span id="toc12">承認の方法</span></h3>



<p>スプレッドシートやフォームなどのサービスと連携させる処理を行うと初回起動時のみ承認作業が必要です。アクセス許可が必要なのは、アカウント毎ではなく、1つのアプリ(スプレッドシート毎)に対して必ず1度承認しないといけません。</p>



<h4 class="wp-block-heading">権限を確認</h4>



<p>最初に実行する場合は、認証が必要となります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="540" height="282" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0139.png" alt="スクリプトの承認手順1" class="wp-image-22875" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0139.png 540w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0139-300x157.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0139-500x261.png 500w" sizes="(max-width: 540px) 100vw, 540px" /></figure>



<h4 class="wp-block-heading">「詳細」をクリック</h4>



<p>「詳細」から「無題のプロジェクト(安全ではないページ)に移動」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="553" height="265" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0140.png" alt="スクリプトの承認手順2" class="wp-image-22876" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0140.png 553w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0140-300x144.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0140-500x240.png 500w" sizes="(max-width: 553px) 100vw, 553px" /></figure>



<h4 class="wp-block-heading">「許可」をクリック</h4>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0141.png" alt="スクリプトの承認手順3" class="wp-image-22877" width="259" height="391"/></figure>



<h2 class="wp-block-heading"><span id="toc13">スプレッドシートの操作</span></h2>



<h3 class="wp-block-heading"><span id="toc14">スプレッドシートの取得</span></h3>



<p>SpreadsheetAppの配下のスプレッドシートファイルを取得します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="546" height="270" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0151.png" alt="Spreadsheetクラスのスプレッドシート" class="wp-image-22878" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0151.png 546w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0151-300x148.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0151-500x247.png 500w" sizes="(max-width: 546px) 100vw, 546px" /></figure>



<p>[ スプレッドシートの取得方法 ]<br>スプレッドシートの取得方法は、3つあります。</p>



<ul class="wp-block-list">
<li>アクティブなスプレッドシートを取得する方法</li>



<li>URLを使って取得する方法</li>



<li>IDを使って取得する。</li>
</ul>



<h4 class="wp-block-heading">アクティブなスプレッドシートを取得する方法</h4>



<p>コンテナバインドスクリプトで有効な方法です。Excelで言えば「ブック」にあたります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="598" height="272" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0152.png" alt="アクティブなスプレッドシートを取得する方法" class="wp-image-22879" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0152.png 598w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0152-300x136.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0152-500x227.png 500w" sizes="(max-width: 598px) 100vw, 598px" /></figure>



<h4 class="wp-block-heading">URLを使って取得する方法</h4>



<p>バインドされていないスプレッドシートを取得する方法です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="591" height="451" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0153.png" alt="URLを使ってスプレッドシートを取得する方法" class="wp-image-22880" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0153.png 591w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0153-300x229.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0153-500x382.png 500w" sizes="(max-width: 591px) 100vw, 591px" /></figure>



<p>ドライブIDとURLは、ファイルやフォルダを移動しても不変です。スクリプトを作成した後にファイルの場所やフォルダ構成を変更しても、スクリプトに記述したID、URLを修正する必要はありません。</p>



<h4 class="wp-block-heading">IDを使って取得する方法</h4>



<p>バインドされていないスプレッドシートを取得する方法です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="606" height="525" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0154.png" alt="IDを使ってスプレッドシートを取得する方法" class="wp-image-22881" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0154.png 606w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0154-300x260.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0154-500x433.png 500w" sizes="(max-width: 606px) 100vw, 606px" /></figure>



<h3 class="wp-block-heading"><span id="toc15">スプレッドシートのコピー</span></h3>



<p>GASでスプレッドシートをコピーします。ここでは、以下の「無題のスプレッドシート」の複製を作成します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="592" height="523" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0161.png" alt="スプレッドシートのコピー" class="wp-image-22882" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0161.png 592w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0161-300x265.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0161-500x442.png 500w" sizes="(max-width: 592px) 100vw, 592px" /></figure>



<h4 class="wp-block-heading">スクリプトの作成</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="588" height="288" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0162.png" alt="コピーのスクリプトの作成" class="wp-image-22883" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0162.png 588w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0162-300x147.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0162-500x245.png 500w" sizes="(max-width: 588px) 100vw, 588px" /></figure>



<h4 class="wp-block-heading">実行結果</h4>



<p>スプレッドシートが複製されました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="589" height="549" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0163.png" alt="スクリプトの実行結果" class="wp-image-22884" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0163.png 589w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0163-300x280.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0163-500x466.png 500w" sizes="(max-width: 589px) 100vw, 589px" /></figure>



<h2 class="wp-block-heading"><span id="toc16">シートの操作</span></h2>



<h3 class="wp-block-heading"><span id="toc17">シートの取得</span></h3>



<p>[ シートの取得方法 ]<br>スプレッドシートの取得方法は、3つあります。</p>



<ul class="wp-block-list">
<li>SpreadsheetAppクラスからアクティブシートを取得する方法</li>



<li>Spreadsheetクラスからシート名で取得する方法</li>



<li>Spreadsheetクラスから配列で取得する方法。</li>
</ul>



<h4 class="wp-block-heading">SpreadsheetAppクラスからアクティブなシートを取得する。</h4>



<p>クラスが持っている機能 (メンバー)を使用する方法です。例えばSpreadsheetAppクラスのgetActiveSheet()というメンバーを使ってSpreadsheetクラスを飛び越え、Sheetを取得する方法です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="554" height="623" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0171.png" alt="アクティブなシートの取得" class="wp-image-22885" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0171.png 554w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0171-300x337.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0171-500x562.png 500w" sizes="(max-width: 554px) 100vw, 554px" /></figure>



<p>シート名を特定せず、アクティブなシートが対象となりますのでご注意下さい。この例では、シート1がアクティブとなっている為、シート1に「Hello! GAS!」が書き込まれています。</p>



<h4 class="wp-block-heading">Spreadsheetクラスからシート名で取得する方法</h4>



<p>シート名を指定するので、わかりやすいメリットはありますが、シート名を変更した際は、スクリプトも変更する必要があります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="557" height="615" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0172.png" alt="シート名で取得" class="wp-image-22886" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0172.png 557w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0172-300x331.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0172-500x552.png 500w" sizes="(max-width: 557px) 100vw, 557px" /></figure>



<h4 class="wp-block-heading">Spreadsheetクラスから配列で取得する方法</h4>



<p>SpreadsheetクラスのgetSheets()というメンバーを使って配列として取得する方法です。getSheets()で全シートを取得して、配列を指定してシートを特定します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="552" height="857" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0173.png" alt="配列で取得" class="wp-image-22887" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0173.png 552w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0173-300x466.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0173-500x776.png 500w" sizes="(max-width: 552px) 100vw, 552px" /></figure>



<p>この方法のメリットは、将来シート名を変更した場合でも、動作に影響がないことです。但し、シートの順番に変更が生じると配列に格納されている順番もかわってしまいますので注意が必要です。<br>※一番左のシートがインデックス0となります。</p>



<p></p>



<h3 class="wp-block-heading"><span id="toc18">シートのコピー</span></h3>



<p>スプレッドシートから取得したシートに対してSheetクラスで提供されるメソッドを使うことで様々な操作を行うことができます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="588" height="228" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0181.png" alt="社員名簿(スプレッドシート)" class="wp-image-22889" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0181.png 588w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0181-300x116.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0181-500x194.png 500w" sizes="(max-width: 588px) 100vw, 588px" /></figure>



<h4 class="wp-block-heading">copyTOメソッド</h4>



<p>SheetクラスのcopyTOメソッドは、対象のシートをコピーします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="637" height="524" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0182.png" alt="copyTOメソッド" class="wp-image-22890" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0182.png 637w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0182-300x247.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0182-500x411.png 500w" sizes="(max-width: 637px) 100vw, 637px" /></figure>



<p>シートのコピーができました。</p>



<p>留意:<br>コピー対象の元シートが1つしかない場合は、シートの取得はgetActiveSheetで良いですが、アクティブなシートがづれていたりすることがありますので、複数のシートがある場合は、コピー専用の元シートを作成して、シート名を指定するgetSheetBynameで取得するのが良いでしょう。</p>



<h4 class="wp-block-heading">getSheetByNameメソッド</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="636" height="770" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0183.png" alt="getSheetByNameメソッド" class="wp-image-22891" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0183.png 636w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0183-300x363.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0183-500x605.png 500w" sizes="(max-width: 636px) 100vw, 636px" /></figure>



<h3 class="wp-block-heading"><span id="toc19">シート名をセットする。</span></h3>



<p>copyToメソッドでコピーしたコピーしたシートは、「(元シート名)のコピー」という名前となりますので、任意の名前に変更する場合は、SheetクラスのsetNameメソッドを使います。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="615" height="501" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0184.png" alt="シート名の書き換え" class="wp-image-22892" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0184.png 615w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0184-300x244.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0184-500x407.png 500w" sizes="(max-width: 615px) 100vw, 615px" /></figure>



<h3 class="wp-block-heading"><span id="toc20">シートをクリアする。</span></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="613" height="190" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0185.png" alt="シートのクリア" class="wp-image-22893" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0185.png 613w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0185-300x93.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0185-500x155.png 500w" sizes="(max-width: 613px) 100vw, 613px" /></figure>



<p>書式は残して値や数式をクリアするには、SheetクラスのclearContentsメソッドを使いますが、コピーしたシートはタイトルは残して中はクリアしたい場合が多いと思います。その場合は、RangeクラスのclearContent(末尾のsは不要)メソッドを使います。文字色・背景色・罫線などの書式はクリアされません。</p>



<p>留意:<br>シートのコンテンツをすべてクリアするにはSheetオブジェクトに対してclearContentsメソッドを使用しますが、このような&#8221;タイトルを残して&#8221;という特定範囲のコンテンツをクリアするにはRangeオブジェクトに対してclearContentメソッドを使用します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="616" height="496" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0186.png" alt="clearContentメソッド" class="wp-image-22894" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0186.png 616w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0186-300x242.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0186-500x403.png 500w" sizes="(max-width: 616px) 100vw, 616px" /></figure>



<h2 class="wp-block-heading"><span id="toc21">セルの操作</span></h2>



<h3 class="wp-block-heading"><span id="toc22">セルを指定して取得する。</span></h3>



<p>セルやセル範囲を指定して取得する方法として代表的なものは、2つあります。</p>



<ul class="wp-block-list">
<li>アドレスを指定して取得する方法</li>



<li>行列を指定して取得する方法</li>
</ul>



<p>以下のシートを例に解説します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="619" height="226" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0191.png" alt="社員名簿(スプレッドシート)" class="wp-image-22895" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0191.png 619w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0191-300x110.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0191-500x183.png 500w" sizes="(max-width: 619px) 100vw, 619px" /></figure>



<h4 class="wp-block-heading">アドレスを指定して取得する方法</h4>



<p>SheetクラスのgetRange()というメンバーを使ってA1やA1:C1というようにセル番号(アドレス)を指定として取得する方法です。ここでは、中田朋子さんの年齢(D3)を取得します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="623" height="320" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0192.png" alt="アドレスを指定して取得する方法" class="wp-image-22896" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0192.png 623w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0192-300x154.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0192-500x257.png 500w" sizes="(max-width: 623px) 100vw, 623px" /></figure>



<h4 class="wp-block-heading">行列を指定して取得する方法</h4>



<p>SheetクラスのgetRange()というメンバーを使って行列を指定して範囲を取得する方法です。中田朋子さんの年齢は、3行目の4列目なので、getRange(3,4)となります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="626" height="370" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0193.png" alt="行列を指定して取得する方法" class="wp-image-22897" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0193.png 626w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0193-300x177.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0193-500x296.png 500w" sizes="(max-width: 626px) 100vw, 626px" /></figure>



<h5 class="wp-block-heading">複数行を取得する。</h5>



<p>岩井さんから池田さんまで、年齢を全て表示します。セルが1つの時は、getValueを使いますが、セルが複数の場合はgetValuesメソッドを使います。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="571" height="250" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0194.png" alt="複数行を取得する方法" class="wp-image-22898" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0194.png 571w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0194-300x131.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0194-500x219.png 500w" sizes="(max-width: 571px) 100vw, 571px" /></figure>



<p>注意:<br>取得した値は二次元配列となっていますので、arr[縦インデックス][横インデックス]の様にインデックスを指定するか?for文で配列を先頭から取り出すなどします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="575" height="255" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0195.png" alt="二次元配列の取り出し方法" class="wp-image-22899" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0195.png 575w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0195-300x133.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0195-500x222.png 500w" sizes="(max-width: 575px) 100vw, 575px" /></figure>



<h5 class="wp-block-heading">範囲を取得する。</h5>



<p>全員の氏名から年齢までを取得します。取得する範囲の開始セルを指定して、そこから何行分、何列分取り出すかを指定します。</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0196.png" alt="範囲を取得する方法" class="wp-image-22900" width="573" height="494" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0196.png 573w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0196-300x259.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0196-500x431.png 500w" sizes="(max-width: 573px) 100vw, 573px" /></figure>



<h3 class="wp-block-heading"><span id="toc23">セル範囲を自動で取得する</span></h3>



<p>セル範囲が固定しているのであれば、セル番号やセル範囲を指定して取得することで問題はありませんが、データが追加されて取得すべきセル範囲が変わることは良くあります。例えば、新しい社員が入社したり、退職したりすると社員名簿の取得すべきセル範囲は大きく変わります。</p>



<h4 class="wp-block-heading">セル範囲を自動で判別して取得する</h4>



<p>getDataRangeメソッドは、シートにデータが存在する範囲を自動的に判別してセル範囲を取得します。ここでは、社員名簿に2名を追加してみます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="616" height="645" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0197.png" alt="セル範囲を自動で判別して取得する方法" class="wp-image-22901" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0197.png 616w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0197-300x314.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0197-500x524.png 500w" sizes="(max-width: 616px) 100vw, 616px" /></figure>



<p>データのあるA1からF7までの範囲が自動的に判別されて取得されたことが確認できます。<br>注意:<br>1行目や1列目を空白行や空白列とすると、空白行や空白列も含めたセル範囲が取得されますので注意願います。</p>



<h4 class="wp-block-heading">最終行、最終列を自動で判別して取得する。</h4>



<p>データが存在する最終行を取得するgetLastRowメソッドと、最終列を取得するgetLastColomnをgetRangeメソッドと組み合わせて使います。</p>



<p></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="621" height="698" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0198.png" alt="最終行、最終列を自動で判別して取得する。" class="wp-image-22903" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0198.png 621w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0198-300x337.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0198-500x562.png 500w" sizes="(max-width: 621px) 100vw, 621px" /></figure>



<p>列から「性別」を削除して、行から「池田沙也加」さんと「冴木美恵」さんを削除しました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="608" height="328" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas0199.png" alt="自動で判別の例" class="wp-image-22904" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas0199.png 608w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0199-300x162.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas0199-500x270.png 500w" sizes="(max-width: 608px) 100vw, 608px" /></figure>



<h3 class="wp-block-heading"><span id="toc24">セル値の取得・セット</span></h3>



<h4 class="wp-block-heading">セル範囲の値を取得する。</h4>



<p>RangeクラスのgetValueメソッドは、セル範囲のRangeオプジェクトから各セルに入力されている値を取得します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="615" height="658" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas01101.png" alt="セル範囲の値の取得" class="wp-image-22905" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas01101.png 615w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01101-300x321.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01101-500x535.png 500w" sizes="(max-width: 615px) 100vw, 615px" /></figure>



<p>getValuesメソッドでは、セル範囲の値は、2次元配列として取得されます。</p>



<h4 class="wp-block-heading">セル範囲から「見出し行」を削除する。</h4>



<p>getRange(&#8220;A2:F7&#8221;)という固定値で指定してセル範囲を取得する場合は、見出しを外して指定しますが、セル範囲を自動で取得するgetDataRangeメソッドを使って取得する場合は、1行目の見出し行も含まれてしまいます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="611" height="598" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas01102.png" alt="「見出し行」を含んだセル範囲の取得" class="wp-image-22906" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas01102.png 611w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01102-300x294.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01102-500x489.png 500w" sizes="(max-width: 611px) 100vw, 611px" /></figure>



<p>配列から先頭データを取り除くshiftメソッドでvaluesから見出し行のデータを削除します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="628" height="386" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas01103.png" alt="「見出し行」を除いたセル範囲の取得" class="wp-image-22907" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas01103.png 628w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01103-300x184.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01103-500x307.png 500w" sizes="(max-width: 628px) 100vw, 628px" /></figure>



<h4 class="wp-block-heading">セル範囲に値をセットする。</h4>



<p>RangeクラスのsetValueメソッドは、セル範囲に引数で指定した値をセットします。6行目と7行目に次の社員の名簿をセットします。<br>[&#8220;冴木美恵&#8221;,&#8221;さえきみえ&#8221;,&#8221;女&#8221;,39,&#8221;訪問介護員&#8221;,&#8221;&#8221;],<br>[&#8220;静根裕典&#8221;,&#8221;しずねひろのり&#8221;,&#8221;男&#8221;,35,&#8221;訪問介護員&#8221;,&#8221;管理者&#8221;]</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="631" height="318" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas01104.png" alt="セル範囲の値をセットする方法" class="wp-image-22908" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas01104.png 631w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01104-300x151.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01104-500x252.png 500w" sizes="(max-width: 631px) 100vw, 631px" /></figure>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://gungii.com/wp/wp-content/uploads/2023/07/gas01105.png" alt="セル範囲の値をセットする例" class="wp-image-22909" width="623" height="581" srcset="https://gungii.com/wp/wp-content/uploads/2023/07/gas01105.png 623w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01105-300x280.png 300w, https://gungii.com/wp/wp-content/uploads/2023/07/gas01105-500x466.png 500w" sizes="(max-width: 623px) 100vw, 623px" /></figure>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Bingウェブマスターツールの簡単な登録方法と便利機能</title>
		<link>https://gungii.com/bwt-info/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Sun, 05 Jun 2022 06:08:57 +0000</pubDate>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[ソフトウェア]]></category>
		<guid isPermaLink="false">https://gungii.com/?p=20271</guid>

					<description><![CDATA[Bingウェブマスターツールとは、Microsoft社のサイト(Bing)のパフォーマンスを確認できる無料の分析ツールです。Googleで言えば、Googleサーチコンソールとなります。つまり、Googleサーチコンソー [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Bingウェブマスターツールとは、Microsoft社のサイト(Bing)のパフォーマンスを確認できる無料の分析ツールです。Googleで言えば、Googleサーチコンソールとなります。つまり、GoogleサーチコンソールがGoogle検索、BingウェブマスターツールがBing検索という事です。<br>「Googleサーチコンソール」や「Googleアナリティクス」を利用している方は多いかと思います。シェアは低いものの、Yahoo!に続いて第3位の検索エンジンとなっていて、Windows10に最初からインストールされているブラウザ「Microsoft Edge」、iPhoneやiPadで提供されている音声アシスタント機能であるSiri、さらにAmazon Echoでも標準の検索エンジンとしてBingが採用されていますので、今後大きくシェアを伸ばしていく可能性もあると言えます。今回、Bingウェブマスターツールの簡単な登録方法をご紹介しますので、これを機会に是非、登録しておきましょう。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-16" checked><label class="toc-title" for="toc-checkbox-16">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">Bingウェブマスターツールの登録方法</a><ol><li><a href="#toc2" tabindex="0">サイトへアクセス</a></li><li><a href="#toc3" tabindex="0">アカウントの登録</a></li><li><a href="#toc4" tabindex="0">データのインポート</a></li></ol></li><li><a href="#toc5" tabindex="0">Bingウェブマスターツールの使い方</a><ol><li><a href="#toc6" tabindex="0">検索パフォーマンス</a></li><li><a href="#toc7" tabindex="0">SEOレポート</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">Bingウェブマスターツールの登録方法</span></h2>



<p>Bingウェブマスターツールへの登録をお考えの方は、「Googleサーチコンソール」や「Googleアナリティクス」を既に利用されていると思われますので、問題ないかとは思いますが、Bingウェブマスターツールへの登録の前、まず先に、Googleサーチコンソールに登録をしておいて下さい。Googleサーチコンソールからデータをインポートできますので、タグの設置や所有権の確認などの手間なく、簡単に登録ができます。</p>



<h3 class="wp-block-heading"><span id="toc2">サイトへアクセス</span></h3>



<p>公式サイトへアクセスして(https://www.bing.com/webmasters/about)、「サインイン」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="496" height="299" src="https://gungii.com/wp/wp-content/uploads/2022/06/bwt01.png" alt="bingウェブマスターの公式サイト" class="wp-image-20273" srcset="https://gungii.com/wp/wp-content/uploads/2022/06/bwt01.png 496w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt01-300x181.png 300w" sizes="(max-width: 496px) 100vw, 496px" /></figure>



<h3 class="wp-block-heading"><span id="toc3">アカウントの登録</span></h3>



<h4 class="wp-block-heading">サインイン</h4>



<p>ここでは、googleアカウントで登録します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="497" height="343" src="https://gungii.com/wp/wp-content/uploads/2022/06/bwt02.png" alt="googleアカウントでサインイン" class="wp-image-20274" srcset="https://gungii.com/wp/wp-content/uploads/2022/06/bwt02.png 497w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt02-300x207.png 300w" sizes="(max-width: 497px) 100vw, 497px" /></figure>



<h4 class="wp-block-heading">アカウントの選択</h4>



<p>連携するアカウントを選択します。(Bingウェブマスターツールへ登録します。)</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="628" height="366" src="https://gungii.com/wp/wp-content/uploads/2022/06/bwt03.png" alt="アカウントの選択" class="wp-image-20275" srcset="https://gungii.com/wp/wp-content/uploads/2022/06/bwt03.png 628w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt03-300x175.png 300w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt03-500x291.png 500w" sizes="(max-width: 628px) 100vw, 628px" /></figure>



<h3 class="wp-block-heading"><span id="toc4">データのインポート</span></h3>



<h4 class="wp-block-heading">「自分のサイトをGSCからインポート」を選択</h4>



<p>左側の「インポート」をクリックします。(Googleサーチコンソールからインポートします。)<br>注意:右側の゛自分のサイトのURL゛を入力する必要はありません。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="622" height="341" src="https://gungii.com/wp/wp-content/uploads/2022/06/bwt04.png" alt="GSCからのデータのインポート" class="wp-image-20276" srcset="https://gungii.com/wp/wp-content/uploads/2022/06/bwt04.png 622w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt04-300x164.png 300w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt04-500x274.png 500w" sizes="(max-width: 622px) 100vw, 622px" /></figure>



<h4 class="wp-block-heading">インポート内容の表示</h4>



<p>インポート内容が表示されますので、確認して「続行」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="625" height="396" src="https://gungii.com/wp/wp-content/uploads/2022/06/bwt05.png" alt="インポート内容の表示" class="wp-image-20277" srcset="https://gungii.com/wp/wp-content/uploads/2022/06/bwt05.png 625w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt05-300x190.png 300w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt05-500x317.png 500w" sizes="(max-width: 625px) 100vw, 625px" /></figure>



<h4 class="wp-block-heading">アカウントの選択</h4>



<p>Googleサーチコンソールからデータをインポートする為に、アカウントを選択して、「許可」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="578" height="393" src="https://gungii.com/wp/wp-content/uploads/2022/06/bwt06.png" alt="アカウントの選択" class="wp-image-20278" srcset="https://gungii.com/wp/wp-content/uploads/2022/06/bwt06.png 578w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt06-300x204.png 300w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt06-500x340.png 500w" sizes="(max-width: 578px) 100vw, 578px" /></figure>



<h4 class="wp-block-heading">インポートするサイトの選択</h4>



<p>Googleサーチコンソールに登録しているサイトのURLが表示されますので、必要なサイトを選択して「インポート」をクリックします。<br>※全てのサイトをインポートする場合は、そのまま「インポート」をクリックします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="583" height="376" src="https://gungii.com/wp/wp-content/uploads/2022/06/bwt07.png" alt="サイトの選択" class="wp-image-20279" srcset="https://gungii.com/wp/wp-content/uploads/2022/06/bwt07.png 583w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt07-300x193.png 300w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt07-500x322.png 500w" sizes="(max-width: 583px) 100vw, 583px" /></figure>



<h4 class="wp-block-heading">完了</h4>



<p>インポートが終わりましたので、「完了」をクリックします。これで、Bingウェブマスターツールの登録は完了です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="584" height="373" src="https://gungii.com/wp/wp-content/uploads/2022/06/bwt08.png" alt="完了画面" class="wp-image-20280" srcset="https://gungii.com/wp/wp-content/uploads/2022/06/bwt08.png 584w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt08-300x192.png 300w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt08-500x319.png 500w" sizes="(max-width: 584px) 100vw, 584px" /></figure>



<h2 class="wp-block-heading"><span id="toc5">Bingウェブマスターツールの使い方</span></h2>



<p>色々な機能がありますが、「Googleサーチコンソール」や「Googleアナリティクス」を利用されている方であれば使い方や見方は、説明の必要はないと思いますので、ここでは、メインの「検索パフォーマンス」と「SEOレポート」についてご紹介します。</p>



<h3 class="wp-block-heading"><span id="toc6">検索パフォーマンス</span></h3>



<p>Bingウェブマスターツールと、Googleサーチコンソールの画面を比較して見ます。ここは、どちらもそれほど変わりません。</p>



<h4 class="wp-block-heading">Bingウェブマスターツール</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="618" height="761" src="https://gungii.com/wp/wp-content/uploads/2022/06/bwt11.png" alt="Bingウェブマスターツールの検索パフォーマンス" class="wp-image-20281" srcset="https://gungii.com/wp/wp-content/uploads/2022/06/bwt11.png 618w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt11-300x369.png 300w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt11-500x616.png 500w" sizes="(max-width: 618px) 100vw, 618px" /></figure>



<h4 class="wp-block-heading">Googleサーチコンソール</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="596" height="871" src="https://gungii.com/wp/wp-content/uploads/2022/06/bwt12.png" alt="Googleサーチコンソールの検索パフォーマンス" class="wp-image-20282" srcset="https://gungii.com/wp/wp-content/uploads/2022/06/bwt12.png 596w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt12-300x438.png 300w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt12-500x731.png 500w" sizes="(max-width: 596px) 100vw, 596px" /></figure>



<h3 class="wp-block-heading"><span id="toc7">SEOレポート</span></h3>



<p>このSEOレポートは、Googleサーチコンソールにはない機能です。SEO対策としてできていない箇所を具体的に指摘してくれますので、どこを直せば良いのかがすぐにわかります。SEO対策に詳しくない者にとっては、とても勉強になります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="618" height="416" src="https://gungii.com/wp/wp-content/uploads/2022/06/bwt13.png" alt="BingウェブマスターツールのSEOレポート" class="wp-image-20283" srcset="https://gungii.com/wp/wp-content/uploads/2022/06/bwt13.png 618w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt13-300x202.png 300w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt13-500x337.png 500w" sizes="(max-width: 618px) 100vw, 618px" /></figure>



<p>例えば、標記の「説明が長すぎか、短すぎます。」というエラーは、私の場合、カテゴリーページにdescriptionが記載されていなかったエラーです。早速、カテゴリーページに記載してエラーは解除できました。<br>※カテゴリーページにもdescriptionが必要なことを気づかされました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="563" height="251" src="https://gungii.com/wp/wp-content/uploads/2022/06/bwt14.png" alt="カテゴリページのメタディスクリプション" class="wp-image-20284" srcset="https://gungii.com/wp/wp-content/uploads/2022/06/bwt14.png 563w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt14-300x134.png 300w, https://gungii.com/wp/wp-content/uploads/2022/06/bwt14-500x223.png 500w" sizes="(max-width: 563px) 100vw, 563px" /><figcaption>WordPressテーマのCocoonを使っています。</figcaption></figure>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ブラウザで簡単にnoindex,nofollowを確認する方法</title>
		<link>https://gungii.com/noindex/</link>
					<comments>https://gungii.com/noindex/#comments</comments>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Sat, 12 Nov 2016 07:37:01 +0000</pubDate>
				<category><![CDATA[ソフトウェア]]></category>
		<guid isPermaLink="false">http://gungii.com/?p=1123</guid>

					<description><![CDATA[SEOを考えた場合、内容の薄い記事や、他のページと重複していたり、文字数の少ないページなどは、サイト全体の評価も下げますので、このような場合は、検索エンジンにインデックスしてもらわない様に、メタタグにnoindexを記述 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>SEOを考えた場合、内容の薄い記事や、他のページと重複していたり、文字数の少ないページなどは、サイト全体の評価も下げますので、このような場合は、検索エンジンにインデックスしてもらわない様に、メタタグにnoindexを記述します。またページに貼られているリンク先にリンクジュースを渡したくない場合は、nofollowを記述します。<br>一般的には、WordPressのプラグイン「All in One SEO Pack」などを入れて、noindexなどの設定を行いますが、その設定が思い通りに設定されているのかを確認するには、ブラウザから右クリックでソースを開いて１ページづつ確認をしていきます。<br>但し、これをサイトの頁すべてで確認することは、現実的に不可能です。ところが、これを簡単に確認する方法がありますので、ご紹介します。Google ChromeやFirefoxのブラウザを使用していれば、ブラウザでページを閲覧するだけで確認ができます。<br>では、ご紹介する前に、noindexとは何なのか？nofollowとは何か?を整理しておきます。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-18" checked><label class="toc-title" for="toc-checkbox-18">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">noindex,nofollowとは</a><ol><li><a href="#toc2" tabindex="0">noindex</a></li><li><a href="#toc3" tabindex="0">nofollow</a></li></ol></li><li><a href="#toc4" tabindex="0">ソースを開いて確認</a></li><li><a href="#toc5" tabindex="0">ブラウザを閲覧して確認</a><ol><li><a href="#toc6" tabindex="0">FireFox</a></li><li><a href="#toc7" tabindex="0">google</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">noindex,nofollowとは</span></h2>



<h3 class="wp-block-heading"><span id="toc2">noindex</span></h3>



<p>noindexタグは、ウェブページをインデックスさせたくない、つまり検索結果に表示させたくないときに使います。設定したページがgoogleの検索エンジンからインデックスされないようにするための構文です。</p>



<h4 class="wp-block-heading">noindexの設定理由</h4>



<p>標記の通り、コンテンツが薄いページであったり、重複コンテンツになっているページはそのページだけでなく、ドメイン全体の評価に悪影響を及ぼします。例えばCMSで自動生成される様な、アーカイブ、タグ、検索結果ページで、他と重複が発生しますので、noindexを設定します。</p>



<h4 class="wp-block-heading">noindexの設定方法</h4>



<p>noindexとしたいページのHTMLのheadセクションに次のコードを記述します。</p>



<pre class="wp-block-preformatted lang:default decode:true">&lt;meta name=”robots” content=”noindex” /&gt;
</pre>



<p>※XHTMLで記述するときは、最後を「/&gt;」で終了します。<br>metaタグで記述した場合はページ全体に対して有効になります。<br>ワードプレスを使っている場合はAll in One SEOで簡単に設定することができます。</p>



<h3 class="wp-block-heading"><span id="toc3">nofollow</span></h3>



<p>設定したリンクに対してクローラーが辿る事を禁止する設定です。nofollowを設定していないリンクには移動しますが、nofollowが設定されているリンクには移動しないことになります。</p>



<h4 class="wp-block-heading">nogollowの設定理由</h4>



<p>例えば、アフィリエイリンクや、お金をもらって紹介記事を書くような有料リンクには、nofollowを入れなければなりません。Googleも有料リンクへのfollowを禁止しています。又、ブログのコメント欄にスパムリンクを張られる場合がありますので、コメント欄は、nofollowとしておくことが必要です。</p>



<h4 class="wp-block-heading">nofollowの設定方法</h4>



<p>①ページ全体のリンクをnofollowとする場合</p>



<p>nofollowタグは、HTMLのheadセクションに次のコードを記述します。</p>



<pre class="wp-block-preformatted lang:default decode:true">&lt;meta name="robots" content="nofollow"&gt;
</pre>



<p>metaタグで記述した場合はページ全体に対して有効になります。</p>



<p>②個別のリンクをnofllowとする場合</p>



<pre class="wp-block-preformatted lang:default decode:true">&lt;a rel="nofollow" href="http://hogehoge/" &gt;
</pre>



<p>上記のように、aタグに「rel=”nofollow”」と記載すると、リンク個別にnofollow設定を反映する事が可能です。<br>aタグで記述した場合はそのリンクに対してのみ有効になります。</p>



<h2 class="wp-block-heading"><span id="toc4">ソースを開いて確認</span></h2>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="479" height="246" src="https://gungii.com/wp/wp-content/uploads/2016/11/niindex1a.jpg" alt="ソースを開いて確認1" class="wp-image-17910" srcset="https://gungii.com/wp/wp-content/uploads/2016/11/niindex1a.jpg 479w, https://gungii.com/wp/wp-content/uploads/2016/11/niindex1a-300x154.jpg 300w" sizes="(max-width: 479px) 100vw, 479px" /></figure>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="264" height="26" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex2a.jpg" alt="" class="wp-image-17912"/></figure>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="579" height="162" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex3a.jpg" alt="ソースを開いて確認2" class="wp-image-17913" srcset="https://gungii.com/wp/wp-content/uploads/2016/11/noindex3a.jpg 579w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex3a-500x140.jpg 500w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex3a-300x84.jpg 300w" sizes="(max-width: 579px) 100vw, 579px" /></figure>



<p>私のサイトでは、日付別アーカイブは「ALL in One SEO Pack」でnoindexに設定しています。<br><br><br><br>ソースを見てみると、</p>



<pre class="wp-block-preformatted lang:default decode:true">&lt;meta name="robots" content="noindex,follow"&gt;</pre>



<p>となっていて、間違えなく、日付のアーカイブは、インデックスされないようになっています。但し、これをサイトの頁すべてで確認することは、現実的に不可能です。</p>



<div style="height:19px" aria-hidden="true" class="wp-block-spacer"></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-none">

<a href="https://gungii.com/noix-info/" title="【WordPress】検索エンジンに表示させないnoindex設定と確認方法" class="blogcard-wrap internal-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://gungii.com/wp/wp-content/uploads/2021/12/noix-ec-160x90.png" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://gungii.com/wp/wp-content/uploads/2021/12/noix-ec-160x90.png 160w, https://gungii.com/wp/wp-content/uploads/2021/12/noix-ec-120x68.png 120w, https://gungii.com/wp/wp-content/uploads/2021/12/noix-ec-320x180.png 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【WordPress】検索エンジンに表示させないnoindex設定と確認方法</div><div class="blogcard-snippet internal-blogcard-snippet">WordPressの作成途中のサイトや、特定の人にだけ見せるデモサイト、会員サイトなどを検索エンジンに表示させたくない場合のnoindex設定と確認方法をご紹介します。絶対に見られたくない場合は、BASIC認証をお薦めします。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://gungii.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">gungii.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2024.07.25</div></div></div></div></a>
</div>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><span id="toc5">ブラウザを閲覧して確認</span></h2>



<p>ブラウザでページを閲覧して、noindex,nofollowを確認する。</p>



<h3 class="wp-block-heading"><span id="toc6">FireFox</span></h3>



<h4 class="wp-block-heading">アドオン「The Addon Bar」の設定</h4>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="515" height="248" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex4a.jpg" alt="アドオン「The Addon Bar」の設定" class="wp-image-17914" srcset="https://gungii.com/wp/wp-content/uploads/2016/11/noindex4a.jpg 515w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex4a-500x241.jpg 500w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex4a-300x144.jpg 300w" sizes="(max-width: 515px) 100vw, 515px" /></figure>



<p>これにより、ブラウザの下にアドオンバーを表示します。<br>https：//addons.mozilla.org/ja/firefox/addon/the-addon-bar/<br></p>



<h4 class="wp-block-heading">アドオン「Seerobots」の設定</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="514" height="249" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex5a.jpg" alt="アドオン「Seerobots」の設定" class="wp-image-17916" srcset="https://gungii.com/wp/wp-content/uploads/2016/11/noindex5a.jpg 514w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex5a-500x242.jpg 500w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex5a-300x145.jpg 300w" sizes="(max-width: 514px) 100vw, 514px" /></figure>



<p>アドオンバーに、noindex,nofolloeの状態が表示されます。<br>https：//addons.mozilla.org/ja/firefox/addon/seerobots/<br></p>



<h4 class="wp-block-heading">noindex,nofollowの確認</h4>



<p>ブラウザで該当のページを閲覧すると、右下にアドオンバーが表示されます。<br>①表示の識別</p>



<p>ア．noindex,nofollowとも適用されていない。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="244" height="26" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex6a.jpg" alt="アドオンバー" class="wp-image-17917"/></figure>



<p></p>



<p>イ．noindex=ON,nofollow=OFF</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="257" height="28" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex7a.jpg" alt="アドオンバー" class="wp-image-17918"/></figure>



<p></p>



<p>ウ．noindex,nofollowともに適用されている。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="259" height="24" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex8a.jpg" alt="アドオンバー" class="wp-image-17919"/></figure>



<p></p>



<h4 class="wp-block-heading">ページ内のnofollowリンクの確認</h4>



<p>アドオンバーの確認では、ページ全体のniindexやnofollowの確認でしたが、ページ内に貼られているリンクにnofollowがついているのかを確認します。<br>①アドオン「Highlight NoFollow links」の設定</p>





<a rel="noopener" target="_blank" href="https://addons.mozilla.org/ja/firefox/addon/highlight-nofollow-links" title="https://addons.mozilla.org/ja/firefox/addon/highlight-nofollow-links" class="blogcard-wrap external-blogcard-wrap a-wrap cf"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://s.wordpress.com/mshots/v1/https%3A%2F%2Faddons.mozilla.org%2Fja%2Ffirefox%2Faddon%2Fhighlight-nofollow-links?w=160&#038;h=90" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">https://addons.mozilla.org/ja/firefox/addon/highlight-nofollow-links</div><div class="blogcard-snippet external-blogcard-snippet"></div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://addons.mozilla.org/ja/firefox/addon/highlight-nofollow-links" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">addons.mozilla.org</div></div></div></div></a>




<p>②nofollowリンクの確認</p>



<p>該当のページを閲覧すると、以下のようにnofollowリンクには、赤い点線枠が付きます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="475" height="278" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex10a.jpg" alt="nofollowリンクの確認" class="wp-image-17922" srcset="https://gungii.com/wp/wp-content/uploads/2016/11/noindex10a.jpg 475w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex10a-300x176.jpg 300w" sizes="(max-width: 475px) 100vw, 475px" /></figure>



<h3 class="wp-block-heading"><span id="toc7">google</span></h3>



<p>googlechromeの拡張機能で、「NoFollow」を追加する。</p>



<h4 class="wp-block-heading">NoFollowを検索</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="595" height="412" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex11a.jpg" alt="NoFollowを検索" class="wp-image-17924" srcset="https://gungii.com/wp/wp-content/uploads/2016/11/noindex11a.jpg 595w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex11a-500x346.jpg 500w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex11a-300x208.jpg 300w" sizes="(max-width: 595px) 100vw, 595px" /></figure>



<h4 class="wp-block-heading">Chromeに追加</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="595" height="401" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex12a.jpg" alt="Chromeに追加" class="wp-image-17925" srcset="https://gungii.com/wp/wp-content/uploads/2016/11/noindex12a.jpg 595w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex12a-500x337.jpg 500w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex12a-300x202.jpg 300w" sizes="(max-width: 595px) 100vw, 595px" /></figure>



<h4 class="wp-block-heading">noindex,nofollowの確認</h4>



<p>ブラウザで該当のページを閲覧すると、右下にアドオンバーが表示されます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="481" height="255" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex13a.jpg" alt="noindex,nofollowの確認" class="wp-image-17926" srcset="https://gungii.com/wp/wp-content/uploads/2016/11/noindex13a.jpg 481w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex13a-300x159.jpg 300w" sizes="(max-width: 481px) 100vw, 481px" /></figure>



<p> ①表示の識別 </p>



<p>ア．noindex,nofollowとも適用されていない。</p>



<p>この場合は、何も表示されません。</p>



<p>イ．noindex=ON,nofollow=OFF/noindex=OFF,nofollow=ON</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="403" height="68" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex14a.jpg" alt="アドオンバー" class="wp-image-17927" srcset="https://gungii.com/wp/wp-content/uploads/2016/11/noindex14a.jpg 403w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex14a-300x51.jpg 300w" sizes="(max-width: 403px) 100vw, 403px" /></figure>



<p></p>



<p>ウ．noindex,nofollowともに適用されている。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="192" height="69" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex15a.jpg" alt="アドオンバー" class="wp-image-17928"/></figure>



<p></p>



<h4 class="wp-block-heading">ページ内のnofollowリンクの確認</h4>



<p>アドオンバーの確認では、ページ全体のniindexやnofollowの確認でしたが、ページ内に貼られているリンクにnofollowがついているのかを確認します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="475" height="235" src="https://gungii.com/wp/wp-content/uploads/2016/11/noindex16a.jpg" alt="ページ内のnofollowリンクの確認" class="wp-image-17929" srcset="https://gungii.com/wp/wp-content/uploads/2016/11/noindex16a.jpg 475w, https://gungii.com/wp/wp-content/uploads/2016/11/noindex16a-300x148.jpg 300w" sizes="(max-width: 475px) 100vw, 475px" /></figure>



<p> nofollowリンクには、赤い点線枠が付いています。 </p>
]]></content:encoded>
					
					<wfw:commentRss>https://gungii.com/noindex/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>「Web認印」で作成した印影を、eight判に読み込む方法</title>
		<link>https://gungii.com/webmtm/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Wed, 21 Sep 2016 13:46:45 +0000</pubDate>
				<category><![CDATA[ソフトウェア]]></category>
		<guid isPermaLink="false">http://gungii.com/?p=501</guid>

					<description><![CDATA[目次 Web認印で印影作成Web認印の起動苗字の入力印影をダウンロード印影の保存ファイル名の変更eight判で印影の読み込みeightban.exeの起動Web認印で作成した印影の読み込みeight判のショートカットの作 [&#8230;]]]></description>
										<content:encoded><![CDATA[

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-20" checked><label class="toc-title" for="toc-checkbox-20">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">Web認印で印影作成</a><ol><li><a href="#toc2" tabindex="0">Web認印の起動</a></li><li><a href="#toc3" tabindex="0">苗字の入力</a></li><li><a href="#toc4" tabindex="0">印影をダウンロード</a></li><li><a href="#toc5" tabindex="0">印影の保存</a></li><li><a href="#toc6" tabindex="0">ファイル名の変更</a></li></ol></li><li><a href="#toc7" tabindex="0">eight判で印影の読み込み</a><ol><li><a href="#toc8" tabindex="0">eightban.exeの起動</a></li><li><a href="#toc9" tabindex="0">Web認印で作成した印影の読み込み</a></li></ol></li><li><a href="#toc10" tabindex="0">eight判のショートカットの作成</a></li><li><a href="#toc11" tabindex="0">ショートカットのプロパティ変更</a><ol><li><a href="#toc12" tabindex="0">プロパティ画面の表示</a></li><li><a href="#toc13" tabindex="0">プロパティのリンク先変更</a></li><li><a href="#toc14" tabindex="0">ショートカットの移動</a></li></ol></li><li><a href="#toc15" tabindex="0">eight判で捺印</a><ol><li><a href="#toc16" tabindex="0">ショートカットのWクリック</a></li><li><a href="#toc17" tabindex="0">捺印</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">Web認印で印影作成</span></h2>



<p>白舟書体がフリーで提供している電子印鑑作成ツール「Web認印」で、PDFや電子印鑑にも使える認印を作成して、電子印鑑eight判の陰影として読込、押印する。<br>留意：<br>eight判でも陰影を作成できますが、「Web認印」で作成した陰影は、格段の差です。シャチハタにもフォントを提供している株式会社白舟書体が提供しているフォントにつき見栄えが全く違います。</p>



<h3 class="wp-block-heading"><span id="toc2">Web認印の起動</span></h3>



<p>http：//www.hakusyu.com/webmtm/</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="419" height="362" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm_starta.png" alt="Web認印の起動" class="wp-image-18171" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm_starta.png 419w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm_starta-300x259.png 300w" sizes="(max-width: 419px) 100vw, 419px" /></figure>



<h3 class="wp-block-heading"><span id="toc3">苗字の入力</span></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="360" height="294" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm_myoujia.png" alt="苗字の入力" class="wp-image-18172" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm_myoujia.png 360w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm_myoujia-300x245.png 300w" sizes="(max-width: 360px) 100vw, 360px" /></figure>



<h3 class="wp-block-heading"><span id="toc4">印影をダウンロード</span></h3>



<p>上の画面を綴じて、下の画面で陰影をダウンロード</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="315" height="251" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-dla.png" alt="印影をダウンロード" class="wp-image-18173" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-dla.png 315w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-dla-300x239.png 300w" sizes="(max-width: 315px) 100vw, 315px" /></figure>



<h3 class="wp-block-heading"><span id="toc5">印影の保存</span></h3>



<p>陰影の上で、右クリック</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="498" height="265" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-hozona.png" alt="印影の保存" class="wp-image-18174" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-hozona.png 498w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-hozona-300x160.png 300w" sizes="(max-width: 498px) 100vw, 498px" /></figure>



<h3 class="wp-block-heading"><span id="toc6">ファイル名の変更</span></h3>



<p>陰影ファイルを見て、誰の陰影かわかる様にファイル名を変更します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="265" height="82" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-fnamea.png" alt="ファイル名の変更" class="wp-image-18175"/></figure>



<h2 class="wp-block-heading"><span id="toc7">eight判で印影の読み込み</span></h2>



<h3 class="wp-block-heading"><span id="toc8">eightban.exeの起動</span></h3>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="596" height="716" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-starta.png" alt="eightban.exeの起動" class="wp-image-18176" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-starta.png 596w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-starta-500x601.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-starta-300x360.png 300w" sizes="(max-width: 596px) 100vw, 596px" /></figure>



<h3 class="wp-block-heading"><span id="toc9">Web認印で作成した印影の読み込み</span></h3>



<h4 class="wp-block-heading">読込のレ点をチェック</h4>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="368" height="336" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-reada.png" alt="読込のレ点をチェック" class="wp-image-18177" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-reada.png 368w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-reada-300x274.png 300w" sizes="(max-width: 368px) 100vw, 368px" /></figure>



<div align="center">eightban37のフォルダに格納しましたので、フォルダを開きます。</div>



<h4 class="wp-block-heading">ファイルの種類(T)の選択</h4>



<p>①pngで検索</p>



<p>pngで検索すると、innei-nakamura.pngが表示されますので、選択します。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="368" height="268" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-selecta.png" alt="pngで検索" class="wp-image-18180" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-selecta.png 368w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-selecta-300x218.png 300w" sizes="(max-width: 368px) 100vw, 368px" /></figure>



<p>②読み込み欄へのURLの取り込み</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="344" height="46" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-urla.png" alt="URLの取り込み" class="wp-image-18181" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-urla.png 344w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-urla-300x40.png 300w" sizes="(max-width: 344px) 100vw, 344px" /></figure>



<h4 class="wp-block-heading">印影の読み込み</h4>



<p>①画面の表示</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="373" height="297" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-dsplaya.png" alt="画面の表示" class="wp-image-18182" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-dsplaya.png 373w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-dsplaya-300x239.png 300w" sizes="(max-width: 373px) 100vw, 373px" /></figure>



<p>注意：読込で、C:￥Users￥N2￥Desktop￥eightban37￥innei_nakamura.pngとURLが参照されますので、innei_nakamura.pngをより移動させますと、陰影が消えてしまいますので、ご注意ください。</p>



<p>②設定の変更</p>



<p>以前の陰影の設定が残っていたら、変更します。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="522" height="117" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-changea.png" alt="設定の変更" class="wp-image-18183" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-changea.png 522w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-changea-500x112.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-changea-300x67.png 300w" sizes="(max-width: 522px) 100vw, 522px" /></figure>



<div align="center">レ点のチェックを外す。</div>



<p>③大きさの変更</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="528" height="178" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-sizea.png" alt="大きさの変更" class="wp-image-18184" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-sizea.png 528w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-sizea-500x169.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-sizea-300x101.png 300w" sizes="(max-width: 528px) 100vw, 528px" /></figure>



<h2 class="wp-block-heading"><span id="toc10">eight判のショートカットの作成</span></h2>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="628" height="401" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-shortcuta.png" alt="eight判のショートカットの作成" class="wp-image-18185" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-shortcuta.png 628w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-shortcuta-500x319.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-shortcuta-300x192.png 300w" sizes="(max-width: 628px) 100vw, 628px" /></figure>



<p>ExcelやWordを使用している際に、印鑑がすぐに使用できるようショートカットを作成しておきます。<br>留意：<br>ショートカットのリンク先を指定しておけば、ショートカットのクリックで、印影がクリップボードに書き込まれますので、印影をそのまま貼り付けることができます。<br></p>



<h2 class="wp-block-heading"><span id="toc11">ショートカットのプロパティ変更</span></h2>



<h3 class="wp-block-heading"><span id="toc12">プロパティ画面の表示</span></h3>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="650" height="340" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-propatya.png" alt="プロパティ画面の表示" class="wp-image-18186" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-propatya.png 650w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-propatya-500x262.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-propatya-300x157.png 300w" sizes="(max-width: 650px) 100vw, 650px" /></figure>



<h3 class="wp-block-heading"><span id="toc13">プロパティのリンク先変更</span></h3>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="600" height="508" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-linka.png" alt="プロパティのリンク先変更" class="wp-image-18187" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-linka.png 600w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-linka-500x423.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-linka-300x254.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></figure>



<h3 class="wp-block-heading"><span id="toc14">ショートカットの移動</span></h3>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="392" height="186" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-idoua.png" alt="ショートカットの移動" class="wp-image-18188" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-idoua.png 392w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-idoua-300x142.png 300w" sizes="(max-width: 392px) 100vw, 392px" /></figure>



<p>使いやすいように、ショートカットをデスクトップへ出しておきます。<br></p>



<h2 class="wp-block-heading"><span id="toc15">eight判で捺印</span></h2>



<h3 class="wp-block-heading"><span id="toc16">ショートカットのWクリック</span></h3>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="606" height="92" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-natsuin1a.png" alt="ショートカットのWクリック" class="wp-image-18189" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-natsuin1a.png 606w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-natsuin1a-500x76.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-natsuin1a-300x46.png 300w" sizes="(max-width: 606px) 100vw, 606px" /></figure>



<p>作成した印影のショートカットをWクリックすることで、印影をクリップボードに書き込みます。<br></p>



<h3 class="wp-block-heading"><span id="toc17">捺印</span></h3>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="524" height="313" src="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-natsuin2a.png" alt="捺印" class="wp-image-18190" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-natsuin2a.png 524w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-natsuin2a-500x299.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/webmtm-natsuin2a-300x179.png 300w" sizes="(max-width: 524px) 100vw, 524px" /></figure>



<p>ショートカットをクリックした後、右クリックで、「貼り付け(P)」を選択すると、押印されます。<br></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>電子印鑑eight判のインストールと使い方</title>
		<link>https://gungii.com/eightban/</link>
					<comments>https://gungii.com/eightban/#comments</comments>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Tue, 20 Sep 2016 15:40:00 +0000</pubDate>
				<category><![CDATA[ソフトウェア]]></category>
		<guid isPermaLink="false">http://gungii.com/?p=463</guid>

					<description><![CDATA[eight判とは、電子文書などで利用する“日付印”の画像を作成する印鑑フリーソフトです。所属部署名、日付、名前が入った印影を、好みにカスタマイズして作成できます。フォント・カラー、枠の大きさ・太さの変更、位置の微調整がで [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>eight判とは、電子文書などで利用する“日付印”の画像を作成する印鑑フリーソフトです。<br>所属部署名、日付、名前が入った印影を、好みにカスタマイズして作成できます。フォント・カラー、枠の大きさ・太さの変更、位置の微調整ができます。デート印の他にも、認印、親展などのハンコも作成できます。<br>＜特徴＞<br>・自由にカスタマイズ可能。<br>・EMF(Enhanced Meta File)形式のため、拡大縮小してもギザギザになりません。<br>・フォント・カラー、枠の大きさ・太さの変更、位置の微調整ができます。<br>・日付のフォーマット(yy/mm/dd)を自分で設定し呼び出すことができます。<br>・自分以外の名前で設定をファイルに保存でき、後で呼び出せます。<br>・VBAで作成していませんのでExcelなどが必要ありません。<br>・背景を透過することもできます。<br>・BMP,GIF,PNGの読み込みが可能です。<br>・倍率を変更して保存できます。<br>・設定ファイルを指定して起動し、クリップボードに出力して終了できます。<br>・メタファイルにコンピュータ名等の情報をセットできます。<br>・パスワードでセキュリティがかけられます。<br>・ログをとることができます。<br>・アイコンを表示しクリックで操作可能<br>・ポップアップメニューより操作可能</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-22" checked><label class="toc-title" for="toc-checkbox-22">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">eight判のダウンロード</a></li><li><a href="#toc2" tabindex="0">eight判のインストール</a></li><li><a href="#toc3" tabindex="0">eight判の使い方</a><ol><li><a href="#toc4" tabindex="0">印影の作成</a></li></ol></li><li><a href="#toc5" tabindex="0">ショートカットの作成</a><ol><li><a href="#toc6" tabindex="0">電子印鑑のショートカット作成</a></li><li><a href="#toc7" tabindex="0">ショートカットのプロパティ変更</a></li></ol></li><li><a href="#toc8" tabindex="0">eight判で捺印</a><ol><li><a href="#toc9" tabindex="0">ショートカットのクリック</a></li><li><a href="#toc10" tabindex="0">捺印</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">eight判のダウンロード</span></h2>



<p>http：//www.vector.co.jp/soft/winnt/business/se420082.html</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="606" height="890" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-dla.png" alt="eight判のダウンロード" class="wp-image-18194" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-dla.png 606w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-dla-500x734.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-dla-300x441.png 300w" sizes="(max-width: 606px) 100vw, 606px" /></figure>



<h2 class="wp-block-heading"><span id="toc2">eight判のインストール</span></h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="519" height="253" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-installa.png" alt="eight判のインストール" class="wp-image-18196" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-installa.png 519w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-installa-500x244.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-installa-300x146.png 300w" sizes="(max-width: 519px) 100vw, 519px" /></figure>



<h2 class="wp-block-heading"><span id="toc3">eight判の使い方</span></h2>



<h3 class="wp-block-heading"><span id="toc4">印影の作成</span></h3>



<h4 class="wp-block-heading">eightban.exeの起動</h4>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="596" height="716" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-starta.png" alt="eightban.exeの起動" class="wp-image-18176" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-starta.png 596w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-starta-500x601.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-starta-300x360.png 300w" sizes="(max-width: 596px) 100vw, 596px" /></figure>



<h4 class="wp-block-heading">印影の選択</h4>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="310" height="117" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-in-kinda.png" alt="印影の選択" class="wp-image-18197" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-in-kinda.png 310w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-in-kinda-300x113.png 300w" sizes="(max-width: 310px) 100vw, 310px" /></figure>



<p>印影は、予め、次の3つが用意されていますので、いづれかを選択した後、変更します。<br><br>①iniの選択</p>



<p>初期値として、以下のデート印が表示されますので、デート印の変更であればそのまま変更します。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="466" height="380" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-in-selecta.png" alt="iniの選択" class="wp-image-18198" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-in-selecta.png 466w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-in-selecta-300x245.png 300w" sizes="(max-width: 466px) 100vw, 466px" /></figure>



<p><br>②iniの読み込み</p>



<p>a.「別名設定読込」をクリックします。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="232" height="90" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ini-reada.png" alt="「別名設定読込」をクリック" class="wp-image-18199"/></figure>



<p>b.該当のiniを選択します。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="497" height="362" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ini-datea.png" alt="該当のiniを選択" class="wp-image-18200" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ini-datea.png 497w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ini-datea-300x219.png 300w" sizes="(max-width: 497px) 100vw, 497px" /></figure>



<div align="center">ここでは、デート印.iniを選択します。</div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="595" height="465" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ini-dspa.png" alt="iniの表示" class="wp-image-18201" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ini-dspa.png 595w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ini-dspa-500x391.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ini-dspa-300x234.png 300w" sizes="(max-width: 595px) 100vw, 595px" /></figure>



<p>③iniの表示<br></p>



<div align="center">ここから、独自のデート印を作成していきます。</div>



<h4 class="wp-block-heading">印影の作成</h4>



<p>①所属の入力</p>



<p>「人事部」と入力して、横方向は0とします。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="327" height="118" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-syozokua.png" alt="所属の入力" class="wp-image-18202" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-syozokua.png 327w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-syozokua-300x108.png 300w" sizes="(max-width: 327px) 100vw, 327px" /></figure>



<p><br>②予備1の削除</p>



<p>「課長」の文字が重なっていますので、ㇾ点を消して、非表示にします。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="329" height="89" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-yobi1a.png" alt="予備1の削除" class="wp-image-18203" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-yobi1a.png 329w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-yobi1a-300x81.png 300w" sizes="(max-width: 329px) 100vw, 329px" /></figure>



<p> ③名前の入力 </p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="328" height="87" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-namea.png" alt="名前の入力" class="wp-image-18204" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-namea.png 328w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-namea-300x80.png 300w" sizes="(max-width: 328px) 100vw, 328px" /></figure>



<p><br>④色の設定</p>



<p>Clolorをクリックすると印影及び文字の色を選択できます。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="481" height="190" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-colora.png" alt="色の設定" class="wp-image-18205" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-colora.png 481w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-colora-300x119.png 300w" sizes="(max-width: 481px) 100vw, 481px" /></figure>



<p><br>⑤終了</p>



<p>印影が作成できましたら、終了をクリックします。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="582" height="159" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-enda.png" alt="終了" class="wp-image-18206" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-enda.png 582w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-enda-500x137.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-enda-300x82.png 300w" sizes="(max-width: 582px) 100vw, 582px" /></figure>



<p><br>⑥印影の保存</p>



<p>a.別名設定保存</p>



<p>上記の印影は残したまま、別の印影を作成する場合は、終了時に「別名設定保存」をクリックします。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="446" height="96" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-hozon1a.png" alt=".別名設定保存" class="wp-image-18207" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-hozon1a.png 446w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-hozon1a-300x65.png 300w" sizes="(max-width: 446px) 100vw, 446px" /></figure>



<p>b.印影に名前を付けて保存</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="547" height="203" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-hozon2a.png" alt="印影に名前を付けて保存" class="wp-image-18208" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-hozon2a.png 547w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-hozon2a-500x186.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-hozon2a-300x111.png 300w" sizes="(max-width: 547px) 100vw, 547px" /></figure>







<h2 class="wp-block-heading"><span id="toc5">ショートカットの作成</span></h2>



<h3 class="wp-block-heading"><span id="toc6">電子印鑑のショートカット作成</span></h3>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="628" height="398" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-shortcuta.png" alt="電子印鑑のショートカット作成" class="wp-image-18209" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-shortcuta.png 628w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-shortcuta-500x317.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-shortcuta-300x190.png 300w" sizes="(max-width: 628px) 100vw, 628px" /></figure>



<p>ExcelやWordを使用している際に、印鑑がすぐに使用できるようショートカットを作成しておきます。<br>留意：<br>ショートカットのリンク先を指定しておけば、ショートカットのクリックで、印影がクリップボードに書き込まれますので、印影をそのまま貼り付けることができます。<br></p>



<h3 class="wp-block-heading"><span id="toc7">ショートカットのプロパティ変更</span></h3>



<h4 class="wp-block-heading">プロパティ画面の表示</h4>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="631" height="346" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-propatya.png" alt="プロパティ画面の表示" class="wp-image-18210" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-propatya.png 631w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-propatya-500x274.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-propatya-300x165.png 300w" sizes="(max-width: 631px) 100vw, 631px" /></figure>



<h4 class="wp-block-heading">プロパティのリンク先の変更</h4>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="573" height="542" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-linka.png" alt="プロパティのリンク先の変更" class="wp-image-18211" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-linka.png 573w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-linka-500x473.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-linka-300x284.png 300w" sizes="(max-width: 573px) 100vw, 573px" /></figure>



<h4 class="wp-block-heading">ショートカットをデスクトップへ移動</h4>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="392" height="186" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-sc-idoua.png" alt="ショートカットをデスクトップへ移動" class="wp-image-18212" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-sc-idoua.png 392w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-sc-idoua-300x142.png 300w" sizes="(max-width: 392px) 100vw, 392px" /></figure>



<p>使いやすいように、ショートカットをデスクトップへ出しておきます。<br></p>



<h2 class="wp-block-heading"><span id="toc8">eight判で捺印</span></h2>



<h3 class="wp-block-heading"><span id="toc9">ショートカットのクリック</span></h3>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="606" height="92" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ouin1a.png" alt="ショートカットのクリック" class="wp-image-18213" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ouin1a.png 606w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ouin1a-500x76.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ouin1a-300x46.png 300w" sizes="(max-width: 606px) 100vw, 606px" /></figure>



<p>作成した印影のショートカットをクリックすることで、印影をクリップボードに書き込みます。<br></p>



<h3 class="wp-block-heading"><span id="toc10">捺印</span></h3>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="522" height="342" src="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ouin2a.png" alt="捺印" class="wp-image-18214" srcset="https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ouin2a.png 522w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ouin2a-500x328.png 500w, https://gungii.com/wp/wp-content/uploads/2016/09/eightban-ouin2a-300x197.png 300w" sizes="(max-width: 522px) 100vw, 522px" /></figure>



<p>ショートカットをクリックした後、右クリックで、「貼り付け(P)」を選択すると、押印されます。</p>




]]></content:encoded>
					
					<wfw:commentRss>https://gungii.com/eightban/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>社内文書は、電子印鑑でペーパーレス化を図ろう。</title>
		<link>https://gungii.com/paperless/</link>
		
		<dc:creator><![CDATA[gungii]]></dc:creator>
		<pubDate>Mon, 19 Sep 2016 16:00:49 +0000</pubDate>
				<category><![CDATA[ソフトウェア]]></category>
		<guid isPermaLink="false">http://gungii.com/?p=458</guid>

					<description><![CDATA[近年、インターネットの普及が進み、ちょっとした書類は、作成したデータをエクセルやPDFで、メールに添付してやりとりをすることが増えています。以前は、各書類をプリントアウトして封筒に詰めて郵送するのが当たり前でしたが、今で [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>近年、インターネットの普及が進み、ちょっとした書類は、作成したデータをエクセルやPDFで、メールに添付してやりとりをすることが増えています。以前は、各書類をプリントアウトして封筒に詰めて郵送するのが当たり前でしたが、今ではこういった書類もメールでやりとりをします。</p>



<p>しかし、押印が必要となると、せっかくExcelやWordのデータで文書を作成したにもかかわらず、データをプリントアウトし、押印したあと、紙の文書でやりとりをするということをやっている人が、結構多いと思います。<br>そんなとき、使えるのが「電子印鑑（デジタルはんこ）」です。<br>電子印鑑は、ネットで検索すれば、フリーソフトも簡単に検索できます。簡単には、手持ちの印鑑を白い紙に押して、それをスキャナーで読み取り、画像編集ソフトを使って切り取り、必要に応じて書類のデータにペーストすることでもできます。電子印鑑は思っている以上に簡単に作れますが、反対に偽造も簡単です。</p>



<p>そこで、気になるのは、電子印鑑が「どんな書類でも使えるのか？」ということです。</p>



<p>結論から言いますと、電子印鑑に法的な効力がないため、現状では個人や企業内での社内文書など「認印」としての使用に限られます。「電子印鑑」 というのは単なる画像の貼り付けなので、法律上は捺印として認められていません。<br>請求書や見積書は捺印が無くても有効ですので、「電子印鑑」を押印してそのままPDFで送付することもできますが、トラブルが発生した場合に 「捺印していない請求書」が、会社にとって不利な状況になることも考えられます。<br>（相手先も相互に認めていれば電子印鑑で効率化することはできます。)</p>



<p>社外との取引にまつわるような書類や法定文書など公式な書類を電子ファイルで送付する場合は、電子印鑑とは別に「電子署名」を行うことが必要です。</p>



<p>結果として、現状では、「電子印鑑」の使用は、個人や企業内での社内文書（例えば、業務日報、出勤簿、残業申請書、有休申請書、稟議書、出張清算書など）に限っての使用となりますが、それでも、1度もプリントアウトせずにパソコン上で作業を完了することができることは、大きなメリットです。</p>







<p></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
