# Excelワークブックの排他制御

**URL:** <https://forum.uipath.com/t/excel/125112>\
**Category:** フォーラム\
**Tags:** activities\
**Created:** [June 14, 2019, 1:44am UTC](https://forum.uipath.com/t/excel/125112 "2019-06-14T01:44:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaishii](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kaishii/32/30903_2.png) [@kaishii](https://forum.uipath.com/u/kaishii)\
**Post date:** [June 14, 2019, 1:44am UTC](https://forum.uipath.com/t/excel/125112/1 "2019-06-14T01:44:45Z")

</div>

いつもありがとうございます。

共有フォルダ上にあるExcelワークブックを編集したいと思います。

Excelのアプリケーションで行われるように、ワークブックを開いたときにロック取得、  
閉じるとロック解除、のようなことは実現できないでしょうか？

Excel Application Scope では、他人がロックしていてもお構いなしにワークブックを開  
き、結果は別ファイルに保存されてしまいます。

Excel Application Scope でないアクティビティを使用すると、その都度のロック確認に  
なり、処理の途中でワークブックの内容が変化する可能性があり、要件を満たしません。

こちらで試したこと

１．Open ApplicationまたはStart Processで目的のワークブックを開き、Excel  
Application Scope で編集  
→別ファイルに保存されました。

２．Open ApplicationまたはStart Processで目的のワークブックを開き、Excel  
Application Scope でないアクティビティで編集  
→エラーになりました。

３．手作業で目的のワークブックを開いておき、Excel Application Scope で編集  
→うまくいきました。

ほかに方法がない場合は３が解決策になりますが、１と３の結果がなぜ違うのか疑問に感  
じます。

よろしくお願いします。

---

<div class="post-metadata">

**Author:** ![KarthikByggari](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/karthikbyggari/32/430060_2.png) [@KarthikByggari](https://forum.uipath.com/u/KarthikByggari)\
**Post date:** [June 14, 2019, 7:51am UTC](https://forum.uipath.com/t/excel/125112/2 "2019-06-14T07:51:00Z")

</div>

In the properties of Excel Application Scope, uncheck the following option -

 ![40%20PM](https://global.discourse-cdn.com/uipath/original/3X/f/5/f5f22601948d781eb641962a9310e8872fe2399f.png) Screenshot 2019-06-14 at 1.18.40 PM.png

Regards,  
Karthik Byggari

---

<div class="post-metadata">

**Author:** ![kaishii](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kaishii/32/30903_2.png) [@kaishii](https://forum.uipath.com/u/kaishii)\
**Post date:** [June 17, 2019, 1:23am UTC](https://forum.uipath.com/t/excel/125112/4 "2019-06-17T01:23:54Z")

</div>

返信ありがとうございます。

つい先ほど「解決」と書き込んでしまったのですが、誤りでした。

新しいファイルの作成 → Off  
自動保存 → Off

にしたうえで、

１．ＡパソコンでNASのワークブックを開く。  
２．ＢパソコンのExcel Application Scope で１と同じワークブックを開き、内容を編集。  
３．ＢパソコンのExcel Application Scope で「ワークブックを保存」アクティビティを  
呼び出し。

以上の結果、Ｂパソコンのドキュメントフォルダにワークブックが保存されました。

Excel Application Scope でワークブックを開いている間、ロックがかかることは分かっ  
たのでそれは良いのですが、目的のワークブックに上書きされないことがあるので、注意  
が必要だと思いました。

目的のワークブックに上書きされたかの確認は必須で、その方法はExcel Application  
Scope終了後にワークブックの内容を検証する。こういうことが必要なんでしょうか。
