HOWTO: Invoke the Shell's File Properties Dialog Box Q179377  SHELLEXECUTEINFO sei;  ZeroMemory(&sei,sizeof(sei));
  sei.cbSize = sizeof(sei);
  sei.lpFile = szPathOfFileToLaunchPropertiesOf;
  sei.lpVerb = "properties";
  sei.fMask  = SEE_MASK_INVOKEIDLIST;
  ShellExecuteEx(&sei); 

解决方案 »

  1.   

    估计得一个一个获取了
    Dim wordApp As New Word.Application
    Dim wordDoc As New Word.Document
    wordApp.Documents.Open "e:\test.doc"With wordApp.ActiveDocument
        Print .Words.Count
        Print .Paragraphs.Count
        Print .ActiveTheme
    End With
    wordApp.ActiveDocument.Close
    Set wordApp = Nothing
    祝你好运!
      

  2.   

    Public Declare Function FindFirstFile Lib "kernel32" _
        Alias "FindFirstFileA" _
       (ByVal lpFileName As String, _
        lpFindFileData As WIN32_FIND_DATA) As Long
        
    Public Declare Function FindNextFile Lib "kernel32" _
        Alias "FindNextFileA" _
       (ByVal hFindFile As Long, _
        lpFindFileData As WIN32_FIND_DATA) As Long
        
    Public Declare Function FindClose Lib "kernel32" _
        (ByVal hFindFile As Long) As LongPublic Const MAX_PATH = 260Public Type FILETIME
       dwLowDateTime   As Long
       dwHighDateTime  As Long
    End TypePublic Type WIN32_FIND_DATA
       dwFileAttributes As Long
       ftCreationTime   As FILETIME
       ftLastAccessTime As FILETIME
       ftLastWriteTime  As FILETIME
       nFileSizeHigh    As Long
       nFileSizeLow     As Long
       dwReserved0      As Long
       dwReserved1      As Long
       cFileName        As String * MAX_PATH
       cAlternate       As String * 14
    End TypeType SHELLEXECUTEINFO
        cbSize        As Long
        fMask         As Long
        hwnd          As Long
        lpVerb        As String
        lpFile        As String
        lpParameters  As String
        lpDirectory   As String
        nShow         As Long
        hInstApp      As Long
        lpIDList      As Long     'Optional
        lpClass       As String   'Optional
        hkeyClass     As Long     'Optional
        dwHotKey      As Long     'Optional
        hIcon         As Long     'Optional
        hProcess      As Long     'Optional
    End TypePublic Const SEE_MASK_INVOKEIDLIST = &HC
    Public Const SEE_MASK_NOCLOSEPROCESS = &H40
    Public Const SEE_MASK_FLAG_NO_UI = &H400Declare Function ShellExecuteEx Lib "shell32" _
       Alias "ShellExecuteEx" _
      (SEI As SHELLEXECUTEINFO) As Long
    '以下在Form里面
    Private Sub Form_Load()
       Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
       Command1.Caption = "Drive"
       Command2.Caption = "Folder"
       Command3.Caption = "File"
       Command4.Caption = "End"
          LoadFolderInfo  
    End Sub
    Private Sub Command4_Click()
          Unload Me
       End Sub
    Private Sub Command3_Click()   
      'pass the selected item. Bracketing the list item assures 
      'that the text is passed, rather than the list property.    
       ShowProperties (FilesList.List(FilesList.ListIndex))
    End Sub
    Private Sub Command2_Click()
       ShowProperties (FolderList.List(FolderList.ListIndex))
    End Sub
    Private Sub Command1_Click() 
      ShowProperties (Drive1.List(Drive1.ListIndex))
        End Sub
    Private Sub Drive1_Change()     'trap a drive not ready error   
       On Local Error GoTo Drive1_Error     'change to the selected drive   
       ChDrive Drive1.Drive     'get the info
          LoadFolderInfo
         Exit Sub     
    Drive1_Error:   MsgBox "The selected drive is not ready.", _
               vbCritical, "File and Property Demo"
        End Sub
    Private Sub FilesList_Click()   
      'only enable the properies button if both an item is 
      'selected, and that item is not the 'no files' message           
       Command3.Enabled = (FilesList.ListIndex > -1) And _
            (FilesList.List(FilesList.ListIndex)) <> ""
    End Sub
    Private Sub FilesList_DblClick()     'add double-click fuctionality     
       ShowProperties (FilesList.List(FilesList.ListIndex))
    End Sub
    Private Sub FolderList_Click()
        Command2.Enabled = (FolderList.ListIndex > -1)
    End Sub
    Private Sub FolderList_DblClick()  'add double-click fuctionality     
       Dim newPath As String   
       newPath = Trim$(FolderList.List(FolderList.ListIndex))   
      'Required to validate the path
          If Right$(CurDir, 1) <> "\" Then
              ChDir CurDir + "\" + newPath
        Else: ChDir CurDir + newPath
        End If
         'Get items for the new folder
          LoadFolderInfo
        End Sub
    Private Function TrimNull(item As String)   
      'Return a string without the chr$(0) terminator.
          Dim pos As Integer
       pos = InStr(item, Chr$(0))
           If pos Then
             TrimNull = Left$(item, pos - 1)
       Else: TrimNull = item
       End If
    End FunctionPrivate Sub ShowProperties(filename As String)    
       Dim SEI As SHELLEXECUTEINFO
           With SEI
          .cbSize = Len(SEI)
          .fMask = SEE_MASK_NOCLOSEPROCESS Or _
                   SEE_MASK_INVOKEIDLIST Or _ 
                  SEE_MASK_FLAG_NO_UI
          .hwnd = Me.hwnd 
          .lpVerb = "properties"
          .lpFile = filename
          .lpParameters = vbNullChar
          .lpDirectory = vbNullChar
          .nShow = 0
          .hInstApp = 0
          .lpIDList = 0
       End With
           Call ShellExecuteEx(SEI)
        End Sub
    Private Sub LoadFolderInfo()    
      'Display the contents of a drive/folder.
       Dim hFile As Long
       Dim fname As String
       Dim WFD As WIN32_FIND_DATA    
       lbCurrPath.Caption = " Reading files and directories...."
       FilesList.Clear
       FolderList.Clear
       Command3.Enabled = False
       Command2.Enabled = False   
      'Get the first file in the directory (it will usually return ".")   
       hFile = FindFirstFile("*.*" & Chr$(0), WFD)   
      'If nothing returned, bail out.
          If hFile < 0 Then
     Exit Sub
       Do 
         'list the directories in the FolderList.       
          If (WFD.dwFileAttributes And vbDirectory) Then           
            'strip the trailing chr$(0) and add to the folder list.       
             FolderList.AddItem TrimNull(WFD.cFileName)
              Else           
             'strip the trailing chr$(0) and add to the file list.       
              FilesList.AddItem TrimNull(WFD.cFileName)
              End If          
       Loop While FindNextFile(hFile, WFD)
          'Close the search handle           
       Call FindClose(hFile)   
      'update both the current path label and the filelist           
       If FilesList.ListCount = 0 Then FilesList.AddItem ""
       lbCurrPath.Caption = CurDir
       End Sub