簡體   English   中英

使用FSO使用擴展通配符在記事本中打開txt文件

[英]Open txt file in notepad using extension wild card using FSO

我想編寫一個excel宏來打開記事本中的文本文件,使用通配符作為“* .txt”使用FSO對象。 我需要避免shell命令,因為它會在我的工作場所被阻止。

我嘗試了下面的代碼,但它有特定的文件名,也使用shell命令。

Sub M08_OpenTXTFiles()
Dim filename1 As String
filename1 = "C:\L2Q\L2Q-W\SOURCE\TXT\u30033.txt"
Shell ("C:\Windows\system32\notepad.exe" & " " & filename1), vbNormalFocus
End Sub

我需要一個宏來打開一個文本文件,其名稱未知,但只有擴展名在特定文件夾中稱為“* .txt”。

任何幫助,將不勝感激。 謝謝

試試這個代碼

Sub txtopen()
ChDir "F:\Documenti" ' <<< change it
fopen = Application.GetOpenFilename("TXT files (*.txt), *.txt")
If fopen <> False Then
    Shell ("C:\Windows\system32\notepad.exe" & " " & fopen), vbNormalFocus
End If
End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM