# スニペットの使い方

**URL:** <https://forum.uipath.com/t/topic/493040>\
**Category:** フォーラム\
**Created:** [23. November 2022 um 13:39 UTC](https://forum.uipath.com/t/topic/493040 "2022-11-23T13:39:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorby](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gorby/32/543563_2.png) [@gorby](https://forum.uipath.com/u/gorby)\
**Post date:** [23. November 2022 um 13:39 UTC](https://forum.uipath.com/t/topic/493040/1 "2022-11-23T13:39:29Z")

</div>

初めてスニペットを使おうとしています。使いたいのは下記のスニペットです。

> **[ARI - セルの操作を行う Excel VBA マクロ集 (10 本) と実行スニペット - RPA コンポーネント | UiPath Marketplace](https://marketplace.uipath.com/ja/listings/ari-excel-macro-vba-utilization-snippet/questions)**
>
> ARI - セルの操作を行う Excel VBA マクロ集 (10 本) と実行スニペット は、UiPath Marketplace 内の RPA コンポーネントです。✔️ RPA プロフェッショナルたちと共に学び、交流しましょう。

分からないことが多いので幾つか質問させてください。  
１．スニペットは一見普通のアクティビティに見えますが、そのまま自分のワークフローに「VBAの呼び出し」というアクティビティをコピーすれば良いですか？  
２．１．がYESと仮定して、なぜか操作マニュアルに幾つか引数を設定するように書いてありますが、変数に設定してはだめでしょうか？

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [23. November 2022 um 14:24 UTC](https://forum.uipath.com/t/topic/493040/2 "2022-11-23T14:24:50Z")

</div>

> [@gorby](#):
>
> 分からないことが多いので幾つか質問させてください。  
> １．スニペットは一見普通のアクティビティに見えますが、そのまま自分のワークフローに「VBAの呼び出し」というアクティビティをコピーすれば良いですか？  
> ２．１．がYESと仮定して、なぜか操作マニュアルに幾つか引数を設定するように書いてありますが、変数に設定してはだめでしょうか？

Hi @gorby

For snippets in UiPath you can use variables as well because once you drag a snippets its available for you in your xaml

But the marketplace activity which you are referring to is having code snippets for Excel which are to be used in Invoke code and if you need to pass anything into or out of Invoke code then you need to create an argument in the Invoke code activity and pass the variable values to that argument

Cheers

---

<div class="post-metadata">

**Author:** ![gorby](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gorby/32/543563_2.png) [@gorby](https://forum.uipath.com/u/gorby)\
**Post date:** [23. November 2022 um 15:06 UTC](https://forum.uipath.com/t/topic/493040/3 "2022-11-23T15:06:55Z")

</div>

> [@Anil\_G](#):
>
> But the [marketplace](https://marketplace.uipath.com) activity which you are referring to is having code snippets for Excel which are to be used in Invoke code and if you need to pass anything into or out of Invoke code then you need to create an argument in the Invoke code activity and pass the variable values to that argument

あなたが言っていることはよく分かりません。  
結局今回は、引数を設定しなければならないのでしょうか？それとも変数を設定しなければなりませんか？あいまいさを除くため、具体的なワークフローで使い方を教えていただけないでしょうか？

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [23. November 2022 um 15:12 UTC](https://forum.uipath.com/t/topic/493040/4 "2022-11-23T15:12:02Z")

</div>

Hi @gorby

If you open main.xaml this how he is using it

 ![image](https://global.discourse-cdn.com/uipath/original/4X/7/d/7/7d76c2f6059373d1aa4a7bebd676e07e9b906298.png)

To convert argument to variable right click on argument and you can covnert to variable and use

 ![image](https://global.discourse-cdn.com/uipath/original/4X/a/e/a/aeaf8602e5fca6660d30c108bec6199f37147f2a.png)

you can use like this as well

 ![image](https://global.discourse-cdn.com/uipath/original/4X/9/2/4/9249ece146ef36e349992adaefab2667c6acd6da.png)

cheers

---

<div class="post-metadata">

**Author:** ![gorby](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gorby/32/543563_2.png) [@gorby](https://forum.uipath.com/u/gorby)\
**Post date:** [23. November 2022 um 15:16 UTC](https://forum.uipath.com/t/topic/493040/5 "2022-11-23T15:16:52Z")

</div>

まだ、分かりません。  
私が作成したgorby.xamlからスニペットのMain.xamlをどのように呼び出すのでしょうか？  
gorby.xaml側と、スニペットのMain.xaml側の両方の設定を分かりやすく教えてください。

Regards,  
gorby

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [23. November 2022 um 15:21 UTC](https://forum.uipath.com/t/topic/493040/6 "2022-11-23T15:21:48Z")

</div>

> [@gorby](#):
>
> まだ、分かりません。  
> 私が作成したgorby.xamlからスニペットのMain.xamlをどのように呼び出すのでしょうか？  
> gorby.xaml側と、スニペットのMain.xaml側の両方の設定を分かりやすく教えてください。

Hi @gorby

This is how you do it.. Drag a Invoke Workflow file in your gorby.xaml and select the main.xaml(Copy xaml and text files to place where gorby.xaml is there or viceversa)  
Then call main.xaml

 ![image](https://global.discourse-cdn.com/uipath/original/4X/b/3/4/b3435033d6a6d220701e4459525380012313dad6.png)

 ![image](https://global.discourse-cdn.com/uipath/original/4X/c/2/0/c20ec378d7d0cc389b6eb934c5bf2471d8493a65.png)

cheers

---

<div class="post-metadata">

**Author:** ![gorby](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gorby/32/543563_2.png) [@gorby](https://forum.uipath.com/u/gorby)\
**Post date:** [23. November 2022 um 19:21 UTC](https://forum.uipath.com/t/topic/493040/7 "2022-11-23T19:21:04Z")

</div>

スニペットのxamlファイルをどのフォルダに配置すれば良いか分かりません。  
UiPath起動画面左にprojectパネルとsnippetパネルが有ります。（画像参照）

 ![snippet](https://global.discourse-cdn.com/uipath/original/4X/b/e/9/be959f193090affc68a7cc2e1dbbc987f064dd75.png)  
私はスニペットはsnippetパネルに配置すべきと思っていましたが、あなたの説明ではsnippetのxamlファイルを、snippetを呼び出すワークフローと同じプロセス内に配置しているように見えます。  
改めて質問します。snippetのxamlファイルをどこに配置すれば良いですか？

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [23. November 2022 um 19:35 UTC](https://forum.uipath.com/t/topic/493040/8 "2022-11-23T19:35:00Z")

</div>

> [@gorby](#):
>
> 私はスニペットはsnippetパネルに配置すべきと思っていましたが、あなたの説明ではsnippetのxamlファイルを、snippetを呼び出すワークフローと同じプロセス内に配置しているように見えます。  
> 改めて質問します。snippetのxamlファイルをどこに配置すれば良いですか？

Hi @gorby

Sorry I misunderstood what you asked for.

Here are the steps to add this as snippets

Click folder icon

 ![image](https://global.discourse-cdn.com/uipath/original/4X/e/4/c/e4c5fb217d50c410a46fc0ce0a385363b5afa570.png)  
Select the folder which contains required snippet files  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/f/6/a/f6a9771fc3a7c15908a192bc9fe70ff7d2dcf639.png)  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/7/d/b/7db561181124f9abb8d51bc6ec3455d499f5bca4.png)  
Done your snippet is added  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/1/5/7/1578ecdc140c2bad671739591243761bbb4fcb01.png)

Hope this solves your issue

And yes if you want to use like snippets for this you have to use arguments..

Cheers

---

<div class="post-metadata">

**Author:** ![ytakayama](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ytakayama/32/263311_2.png) [@ytakayama](https://forum.uipath.com/u/ytakayama)\
**Post date:** [24. November 2022 um 06:10 UTC](https://forum.uipath.com/t/topic/493040/9 "2022-11-24T06:10:58Z")

</div>

@gorby

> １．スニペットは一見普通のアクティビティに見えますが、そのまま自分のワークフローに「VBAの呼び出し」というアクティビティをコピーすれば良いですか？

コピーして使うので良いと思います。  
このスニペットとして提供されているのはどちらかというと各Excelマクロが主な内容なので、ご自身のフロー上でマクロを使いたい箇所にコピーしてあげればよいと思います。

２．１．がYESと仮定して、なぜか操作マニュアルに幾つか引数を設定するように書いてありますが、変数に設定してはだめでしょうか？

変数に変えてもいいですよ。  
恐らく作者はスニペットの「Main.xaml」を外部から呼び出すこと（=invoke workflowで呼び出すこと）を想定して作っているので引数にしているだけです。  
ご自身のワークフローにコピペして使うのなら変数で良いです。

---

<div class="post-metadata">

**Author:** ![gorby](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gorby/32/543563_2.png) [@gorby](https://forum.uipath.com/u/gorby)\
**Post date:** [24. November 2022 um 21:45 UTC](https://forum.uipath.com/t/topic/493040/10 "2022-11-24T21:45:00Z")

</div>

> [@ytakayama](#):
>
> ご自身のワークフローにコピペして使うのなら変数で良いです。

ワークフロー呼び出しアクティビティをワークフロー内部で使う通常のアクティビティに変えて使ったことがないので、念のため確認をさせてください。下記の手順でそれが実現可能ですか？  
１．ワークフロー呼び出しアクティビティの引数を変数に変える。  
２．ワークフロー呼び出しアクティビティを呼び出し側ワークフローの中にコピーする。

---

<div class="post-metadata">

**Author:** ![ytakayama](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ytakayama/32/263311_2.png) [@ytakayama](https://forum.uipath.com/u/ytakayama)\
**Post date:** [25. November 2022 um 00:41 UTC](https://forum.uipath.com/t/topic/493040/11 "2022-11-25T00:41:30Z")

</div>

ちょっと齟齬がある気がしますが…  
ワークフロー呼び出しアクティビティはスニペット中にないかと思います。

スニペットとして提供されている「Main.xaml」の中にあるVBA呼び出しアクティビティ（もしくはその上のExcelの呼び出し）をコピーして自身が使いたい場所に張り付けてください。  
その後、引数を使用している箇所はエラーになると思いますので、エラーになってる箇所を変数に変更したらよいと思います。
