在记事本中打开.mpu文件后,我的代码不再能够在zip文件中找到它

时间:2017-01-11 19:59:57

标签: vba excel-vba powershell excel

Sub Unzip2()
Dim FSO As Object
Dim oApp As Object
Dim Fname As Variant
Dim FileNameFolder As Variant
Dim DefPath As String
Dim strDate As String
Dim fileNameInZip As Variant
'direct = "Y:\DataServices\JohnH\MACRO Domestic\AUTO GLS\REAL ZIPS"
zippy = Dir(direct & "\*.zip")
Fname = direct & "\" & zippy


If Fname = False Then
    'Do nothing
Else
    'Root folder for the new folder.
    'You can also use DefPath = "C:\Users\Ron\test\"
    'DefPath = Application.DefaultFilePath
    'If Right(DefPath, 1) <> "\" Then
     '   DefPath = DefPath & "\"
    'End If

    'Create the folder name
    'strDate = Format(Now, " dd-mm-yy h-mm-ss")
    FileNameFolder = direct & "\"

    'Make the normal folder in DefPath
    'MkDir FileNameFolder

    'Extract the files into the newly created folder
    Set oApp = CreateObject("Shell.Application")

    'Change this "*.txt" to extract the files you want
    For Each fileNameInZip In oApp.Namespace(Fname).Items
        If LCase(fileNameInZip) Like LCase("*.MPU") Then
            oApp.Namespace(FileNameFolder).CopyHere _
                    oApp.Namespace(Fname).Items.Item(CStr(fileNameInZip))
        End If
    Next

   ' MsgBox "You find the files here: " & FileNameFolder

    On Error Resume Next
    Set FSO = CreateObject("scripting.filesystemobject")
    FSO.DeleteFolder Environ("Temp") & "\Temporary Directory*", True
End If
'direct = "Y:\Excel\EPICAC\NEW FILES\RESULTS\"
MkDir (direct & "\" & "Results")

End Sub

我使用上面的代码来提取带有.mpu文件的拉链(实际上只是一个文本文件),然后打开并读取一些数据。

但是,我今天必须手动从MPU中读取MPU中的一些数据并在记事本中打开它。现在,当我进入.zip时,文件类型中不再显示文件类型,并且代码无法识别文件中是否有任何MPU。

有没有办法扭转它,所以Windows不能从文件名中删除.mpu或者我可以查看文件类型的方式?

1 个答案:

答案 0 :(得分:-1)

我通过更改文件资源管理器设置来修复它,以便不隐藏已知的文件路径。