5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PAD: あるフォルダの最新ファイルを開く

Posted at

目的

  • 困ってる人がいたのでその手助けの為のSample

概要

  1. 特定のフォルダのExcelファイルの一覧を更新日付でソートして取得
  2. 最新(一番最初のファイル)を開く

そう、非常に単純ですね。

PAD

image.png

補足

  • フォルダー内のファイルを取得
    • ファイルフィルター:Excelに限定したい場合は拡張子で指定したほうが良いね
    • 並び替え基準:最新ファイル拾いたいってことで。
  • Excel の起動
    • ドキュメントパス:↑で取得した一覧の最初を取得する為の記述 %Files[0]%
コピペ用PAD
Folder.GetFiles Folder: $'''C:\\Users\\hoge\\OneDrive\\ドキュメント\\LINQPad Queries\\CodeIQ''' FileFilter: $'''*.xlsx''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.LastModified SortDescending1: True SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files
Excel.LaunchAndOpen Path: Files[0] Visible: True ReadOnly: True LoadAddInsAndMacros: False Instance=> ExcelInstance
5
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?