<?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>フォルダ | nujonoa_blog</title>
	<atom:link href="https://nujonoa.com/tag/%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80/feed/" rel="self" type="application/rss+xml" />
	<link>https://nujonoa.com</link>
	<description>人生に役立つデータ集</description>
	<lastBuildDate>Tue, 26 Mar 2024 01:42:12 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>

<image>
	<url>https://nujonoa.com/wp-content/uploads/2019/04/cropped-DSC00976-e1554456145409-32x32.jpg</url>
	<title>フォルダ | nujonoa_blog</title>
	<link>https://nujonoa.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>gasでセルの一覧からファイル一覧を作成する方法</title>
		<link>https://nujonoa.com/how-to-create-a-file-list-from-a-list-of-cells-with-gas/</link>
					<comments>https://nujonoa.com/how-to-create-a-file-list-from-a-list-of-cells-with-gas/#respond</comments>
		
		<dc:creator><![CDATA[nujonoa]]></dc:creator>
		<pubDate>Tue, 26 Mar 2024 01:42:09 +0000</pubDate>
				<category><![CDATA[GAS]]></category>
		<category><![CDATA[未分類]]></category>
		<category><![CDATA[フォルダ]]></category>
		<category><![CDATA[ファイル]]></category>
		<category><![CDATA[作成]]></category>
		<guid isPermaLink="false">https://nujonoa.com/?p=24169</guid>

					<description><![CDATA[gasでセルの一覧からファイル一覧を作成する方法 c列の名前一覧からファイルを作り、特定のフォルダに保存。d列にそのリンクを追加するプログラムです。 適宜シート名、フォルダID、列を変更して使用ください。]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">gasでセルの一覧からファイル一覧を作成する方法</h2>



<p>c列の名前一覧からファイルを作り、特定のフォルダに保存。<br>d列にそのリンクを追加するプログラムです。<br><br>適宜シート名、フォルダID、列を変更して使用ください。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
function createSpreadsheetFromColumnC() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName('Sheet1'); // シート名を適宜変更してください
  var folder = DriveApp.getFolderById('FolderID'); // フォルダIDを適宜変更してください

  var range = sheet.getRange('C:C'); // C列の範囲を取得
  var values = range.getValues(); // C列の値を取得

  for (var i = 0; i &lt; values.length; i++) {
    var fileName = values&#x5B;i]&#x5B;0];
    if (fileName !== '') { // ファイル名が空でない場合
      var newSpreadsheet = SpreadsheetApp.create(fileName); // ファイル名で新しいスプレッドシートを作成
      var fileId = newSpreadsheet.getId(); // 新しいスプレッドシートのIDを取得

      // 新しいスプレッドシートの親フォルダを変更して移動
      var file = DriveApp.getFileById(fileId); // 新しいスプレッドシートを取得
      var newFile = file.moveTo(folder); // 新しいスプレッドシートを指定のフォルダに移動
      
      // スプレッドシートのリンクを取得してD列に書き込む
      var spreadsheetLink = SpreadsheetApp.openById(newFile.getId()).getUrl();
      sheet.getRange('D' + (i + 1)).setValue(spreadsheetLink);
    }
  }
}

</pre></div>]]></content:encoded>
					
					<wfw:commentRss>https://nujonoa.com/how-to-create-a-file-list-from-a-list-of-cells-with-gas/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【VBA】SaveAsでファイルに連番を追加し重複を防ぐ方法</title>
		<link>https://nujonoa.com/create-and-save-serial-numbers/</link>
					<comments>https://nujonoa.com/create-and-save-serial-numbers/#respond</comments>
		
		<dc:creator><![CDATA[nujonoa]]></dc:creator>
		<pubDate>Sun, 31 Jan 2021 01:15:16 +0000</pubDate>
				<category><![CDATA[マクロVBA]]></category>
		<category><![CDATA[vba]]></category>
		<category><![CDATA[フォルダ]]></category>
		<category><![CDATA[ファイル]]></category>
		<category><![CDATA[SAVEAS]]></category>
		<category><![CDATA[連番]]></category>
		<guid isPermaLink="false">http://nujonoa.com/?p=8705</guid>

					<description><![CDATA[VBAでSaveAsを使う際に、上書き保存するとそのままエクセルが落ちる現象が散見されました。 そこで、今回は、保存先フォルダに同一の名前が含まれるファイルがあった場合に、連番を付けて登録するプログラムを作成しました。  [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>VBAでSaveAsを使う際に、上書き保存するとそのままエクセルが落ちる現象が散見されました。</p>



<p>そこで、今回は、保存先フォルダに同一の名前が含まれるファイルがあった場合に、<br>連番を付けて登録するプログラムを作成しました。</p>




  <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">【VBA】SaveAsでファイルに連番を追加し重複を防ぐ方法</a></li><li><a href="#toc2" tabindex="0">プログラムの説明</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">【VBA】SaveAsでファイルに連番を追加し重複を防ぐ方法</span></h2>



<p>SaveAsでファイルを保存する際に、<br>連番を追加し重複を防いで保存するプログラムを下記に示します。<br>※ダブルクリックでコピーできます。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: vb; title: ; notranslate">
Sub ファイルに連番を付けて保存()

Application.ScreenUpdating = False

'保存先フォルダを選択*開始**************************************
  MsgBox &quot;保存先フォルダを選択&quot;
  Dim folderPath As Variant
  With Application.FileDialog(msoFileDialogFolderPicker)
  .InitialFileName = &quot;C:\Users\&quot;
   If .Show = 0 Then
     MsgBox &quot;キャンセルボタンをクリックしました。&quot;
     Exit Sub
   End If
   folderPath = .SelectedItems(1)
  End With
'保存先フォルダを選択*終了**************************************

'保存名を入力*開始***************************************************
FileName = Application.InputBox(Prompt:=&quot;名前を入力してください。&quot; &amp; vbLf &amp; vbLf, Type:=2, _
           Default:=ActiveSheet.Name &amp; &quot;_&quot; &amp; Year(Now) &amp; Month(Now) &amp; Day(Now))
   If FileName = False Then
     MsgBox &quot;キャンセルボタンをクリックしました。&quot;
     Exit Sub
   End If
'保存名を入力*終了***************************************************
   
'名前のダブり確認*開始***************************************************
        fn = &quot;*&quot; + FileName + &quot;*&quot;
        fnd = Dir(folderPath + &quot;\&quot; + fn, vbNormal)
        I = 0
        'ファイルがない場合
        If (fnd = &quot;&quot;) Then
            GoTo CONTINUE1
        'ファイルがあった場合
        Else
        Do While fnd &lt;&gt; &quot;&quot;
           fnd = Dir '次のファイル
           I = I + 1
        Loop
        End If
        FileName = FileName &amp; &quot;(&quot; &amp; I &amp; &quot;)&quot;

CONTINUE1:

'名前のダブり確認*終了***************************************************

FName = folderPath &amp; &quot;\&quot; &amp; FileName

'ファイルの保存***************************************************
    Worksheets.copy
    ActiveWorkbook.SaveAs _
    FileName:=FName, _
    FileFormat:=xlOpenXMLWorkbook
　'ファイルを閉じる
  Application.DisplayAlerts = False
    ActiveWorkbook.Close
  Application.DisplayAlerts = True

'ファイルの保存終了***************************************************


Application.ScreenUpdating = True

 
End Sub
</pre></div>


<h2 class="wp-block-heading"><span id="toc2">プログラムの説明</span></h2>



<p>プログラムの肝は、この部分になります。<br>Dir(ファイルパス)関数で、ファイルの存在を確認し、<br>もしファイルがあった場合、連番の数字を繰り上げていく形になります。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: vb; title: ; notranslate">
'名前のダブり確認*開始***************************************************
        fn = &quot;*&quot; + FileName + &quot;*&quot;
        fnd = Dir(folderPath + &quot;\&quot; + fn, vbNormal)
        I = 0
        'ファイルがない場合
        If (fnd = &quot;&quot;) Then
            GoTo CONTINUE1
        'ファイルがあった場合
        Else
        Do While fnd &lt;&gt; &quot;&quot;
           fnd = Dir '次のファイル
           I = I + 1
        Loop
        End If
        FileName = FileName &amp; &quot;(&quot; &amp; I &amp; &quot;)&quot;

CONTINUE1:

'名前のダブり確認*終了***************************************************
</pre></div>


<p>fnでファイル名を含むすべてのファイルを検索していますが、</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: vb; title: ; notranslate">
        fn = &quot;*&quot; + FileName + &quot;.Xls*&quot;
</pre></div>


<p>とすると、エクセルのファイルだけを検出して避けることが可能です。</p>



<p>あとは、名前野田ぶりを無くしたので、ファイルを保存して終了です。<br>Worksheets.copy<br>の後に何もつけないと、新しいブックにコピーされますので、<br>SaveAsで保存して終了です。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: vb; title: ; notranslate">
FName = folderPath &amp; &quot;\&quot; &amp; FileName

'ファイルの保存***************************************************
    Worksheets.copy
    ActiveWorkbook.SaveAs _
    FileName:=FName, _
    FileFormat:=xlOpenXMLWorkbook
　'ファイルを閉じる
  Application.DisplayAlerts = False
    ActiveWorkbook.Close
  Application.DisplayAlerts = True

'ファイルの保存終了***************************************************

</pre></div>


<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://nujonoa.com/create-and-save-serial-numbers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【VBA】DBフォルダ内で名前が一致するファイルを立ち上げる方法</title>
		<link>https://nujonoa.com/launch-the-files-in-the-db-folder/</link>
					<comments>https://nujonoa.com/launch-the-files-in-the-db-folder/#respond</comments>
		
		<dc:creator><![CDATA[nujonoa]]></dc:creator>
		<pubDate>Thu, 28 Jan 2021 13:17:46 +0000</pubDate>
				<category><![CDATA[マクロVBA]]></category>
		<category><![CDATA[データベース]]></category>
		<category><![CDATA[フォルダ]]></category>
		<category><![CDATA[ファイル]]></category>
		<guid isPermaLink="false">http://nujonoa.com/?p=8676</guid>

					<description><![CDATA[エクセルでデータベースを構築するには必須の、データベースファルダからのファイルの取り出し方を紹介していこうと思います。 目次 【VBA】DBフォルダ内で名前が一致するファイルを立ち上げる方法ファイル立ち上げプログラム紹介 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>エクセルでデータベースを構築するには必須の、<br>データベースファルダからのファイルの取り出し方を紹介していこうと思います。</p>




  <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">【VBA】DBフォルダ内で名前が一致するファイルを立ち上げる方法</a></li><li><a href="#toc2" tabindex="0">ファイル立ち上げプログラム紹介</a></li><li><a href="#toc3" tabindex="0">プログラム説明</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">【VBA】DBフォルダ内で名前が一致するファイルを立ち上げる方法</span></h2>



<p>エクセルでデータベースを構築しようと思うと、<br>データを格納してあるフォルダからファイルを取り出すことが第一ステップとなります。</p>



<p>そこで今回は、格納したデータの中から、<br>名前が一致したファイルを取り出す方法を紹介したいと思います。</p>



<h2 class="wp-block-heading"><span id="toc2">ファイル立ち上げプログラム紹介</span></h2>



<p>プラグラムは、下記のとおりです。<br>・イニシャルを変更してご使用ください。<br>※ダブルクリックするとコピーできます。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: vb; title: ; notranslate">
Sub VIEW_FILE()

  Dim folderPath As Variant
  With Application.FileDialog(msoFileDialogFolderPicker)
  .InitialFileName = &quot;C:\Downloads\&quot;'←イニシャルです。変更してください。
   If .Show = 0 Then
     MsgBox &quot;キャンセルされました。&quot;
     Exit Sub
   End If
   folderPath = .SelectedItems(1)
  End With
  
    Dim fnd As String
    Dim fn As String

        fn =  &quot;*&quot; + ActiveCell + &quot;*&quot; 
        fnd = Dir(folderPath + &quot;\&quot; + fn, vbNormal)

        'ファイルがない場合
        If (fnd = &quot;&quot;) Then
             MsgBox &quot;見つかりません&quot;
             Exit Sub
        End If
        '表示
        With CreateObject(&quot;Wscript.Shell&quot;)
        
        Do While fnd &lt;&gt; &quot;&quot;

            .Run &quot;&quot;&quot;&quot; &amp; folderPath &amp; &quot;\&quot; &amp; fnd &amp; &quot;&quot;&quot;&quot;　'ファイル表示
        
           fnd = Dir '次のファイル
        Loop
        
        End With

End Sub
</pre></div>


<h2 class="wp-block-heading"><span id="toc3">プログラム説明</span></h2>



<p>コードの肝は、2点で、<br>①DBフォルダを選択する</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: vb; title: ; notranslate">
 With Application.FileDialog(msoFileDialogFolderPicker)
  .InitialFileName = &quot;C:\Downloads\&quot;'←イニシャルです。変更してください。
   If .Show = 0 Then
     MsgBox &quot;キャンセルされました。&quot;
     Exit Sub
   End If
   folderPath = .SelectedItems(1)
  End With
</pre></div>


<p>②ファイルを立ち上げる</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: vb; title: ; notranslate">
        With CreateObject(&quot;Wscript.Shell&quot;)
        
        Do While fnd &lt;&gt; &quot;&quot;

            .Run &quot;&quot;&quot;&quot; &amp; folderPath &amp; &quot;\&quot; &amp; fnd &amp; &quot;&quot;&quot;&quot;　'ファイル表示
        
           fnd = Dir '次のファイル
        Loop
</pre></div>


<p>になります。<br>DBのフォルダを指定してもいいのですが、<br>少しだけ柔軟性を持たせるために①を追加しています。</p>



<p>②で、名前が一致するファイルを一つずつ開いていきます。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nujonoa.com/launch-the-files-in-the-db-folder/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
