0
すべてのファイルタイプを取得するこのコードがあります。配列に拡張子がある場合は、excludedFile
配列に格納し、実行後に表示する必要があります。配列にファイル名を追加する
Dim excludedFile() as String
Const exts = _
".ade.adp.app.asp.bas.bat.cer.chm.cmd.com.cpl.crt.csh.der.exe.fxp.gadget" & _
".hlp.hta.inf.ins.isp.its.js.jse.ksh.lnk.mad.maf.mag.mam.maq.mar.mas.mat"
Dim file As Variant
file = Application.GetOpenFilename("All Files, *.*", , "Select File", , True)
ReDim data(1 To UBound(file) + 1, 1 To 1)
' filter the list
For i = LBound(file) To UBound(file)
ext = LCase(Mid(file(i), InStrRev(file(i), ".")))
If InStr(1, exts, ext & ".") = 0 Then ' if not blacklisted
count = count + 1
data(count, 1) = file(i)
Else 'I've tried this but returns Subscript out of range error
excludedFile(UBound(excludedFile)) = file(i)
ReDim Preserve excludedFile(1 To UBound(excludedFile) + 1) As String
found = true
End If
Next
if found then
MsgBox Join(excludedFile, vbCrLf)
end if
助けていただければ幸いです。ありがとう。
の作業は、あなたのサブコードの残りの部分を投稿することができますか? 'excludedFile'宣言配列がありません。 InStr(1、exts、ext& "。")= 0の場合、型エラーが発生します。 '(1、ext、ext&"。 ")' no? –
@ShaiRado私の質問が更新されました。そして、そのタイプミスではありません:) – ramj
私は何かを欠いている必要があります、あなたは単一のファイルを開いているので、どのような配列ですか?上に別のループがありますか?あなたは 'GetFolder'コマンドを使う必要がありますか? –