設為首頁收藏本站Access中國

Office中國論壇/Access中國論壇

 找回密碼
 注冊

QQ登錄

只需一步,快速開始

返回列表 發(fā)新帖
查看: 2505|回復: 3
打印 上一主題 下一主題

[討論]發(fā)現(xiàn)了office 2007的一個bug

[復制鏈接]
跳轉(zhuǎn)到指定樓層
1#
發(fā)表于 2006-11-28 05:52:00 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
下面的代碼居然不能運行!紅色的行過不去,提示對象不支持該動作!請各位幫忙測試!
Sub SearchEveryFolder()
    'Declare variables that reference a
    'SearchScope and a ScopeFolder object.
    Dim ss As SearchScope
    Dim sf As ScopeFolder
    'Declare a variable to act as a generic counter.
    Dim lngCount As Long
    'Use a With...End With block to reference the
    'FileSearch object.
    With Application.FileSearch
        'Clear all the parameters of the previous searches.
        'This method doesn't clear the LookIn property or
        'the SearchFolders collection.
        .NewSearch
        'Specify the type of file for which to search.
        'Use the FileType property to specify the first type
        'and then add additional types to the FileTypes collection.
        .FileType = msoFileTypeWebPages
        .FileTypes.Add msoFileTypeExcelWorkbooks
        'Clear the SearchFolder collection by
        'looping through each ScopeFolder object
        'and removing it.
        For lngCount = 1 To .SearchFolders.Count
            .SearchFolders.Remove lngCount
        Next lngCount
        'Loop through the SearchScopes collection to find
        'the scope in which you want to search. In this
        'case the scope is the local machine.
        For Each ss In .SearchScopes
            Select Case ss.Type
                Case msoSearchInMyComputer
                    'Loop through each ScopeFolder in
                    'the ScopeFolders collection of the
                    'SearchScope object.
                    For Each sf In ss.ScopeFolder.ScopeFolders
                        'Call a function that loops through all
                        'of the subfolders of the root ScopeFolder.
                        'This function adds any folders named "1033" to the
                        'SearchFolders collection.
                        Call OutputPaths(sf.ScopeFolders, "1033")
                    Next sf
                Case Else
            End Select
        Next ss
        'Test to see if any ScopeFolders collections were added to
        'the SearchFolders collection.
        If .SearchFolders.Count > 0 Then
            'Set the LookIn property to the path of
            'the first ScopeFolder object in the SearchFolders
            'collection. This is here so that any previous
            'setting of the LookIn property doesn't affect
            'the search.
            .LookIn = .SearchFolders.Item(1).Path
            'Execute the search and test to see if any files
            'were found.
            If .Execute > 0 Then
                'Display the number of files found.
                MsgBox "Files found: " & .FoundFiles.Count
                'Loop through the list of found files and
                'display the path of each one in a message box.
                For lngCount = 1 To .FoundFiles.Count
                    If MsgBox(.FoundFiles.Item(lngCount), vbOKCancel, _
                        "Found files") = vbCancel Then
                       'Break out of the loop
                        lngCount = .FoundFiles.Count
                    End If
                Next lngCount
            End If
        End If
    End With
End Sub



[此貼子已經(jīng)被作者于2006-11-27 21:55:26編輯過]

本帖子中包含更多資源

您需要 登錄 才可以下載或查看,沒有帳號?注冊

x
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享分享 分享淘帖 訂閱訂閱
2#
 樓主| 發(fā)表于 2006-11-28 05:53:00 | 只看該作者
我的這段代碼是摘自于office 2007的幫助中的,不知為何不能執(zhí)行


[此貼子已經(jīng)被作者于2006-11-27 22:04:01編輯過]

本帖子中包含更多資源

您需要 登錄 才可以下載或查看,沒有帳號?注冊

x

點擊這里給我發(fā)消息

3#
發(fā)表于 2006-11-30 02:00:00 | 只看該作者
你引用了Office Object Labrary嗎?
4#
 樓主| 發(fā)表于 2006-11-30 23:14:00 | 只看該作者
這是Excel 2007 開發(fā)人員參考 > 新增內(nèi)容,自 Microsoft Office 2003 以來的對象模型更改里面的內(nèi)容,如下圖。
開來ms是要去除這個這么重要的屬性了,不知道是為了什么?暈!

本帖子中包含更多資源

您需要 登錄 才可以下載或查看,沒有帳號?注冊

x
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則

QQ|站長郵箱|小黑屋|手機版|Office中國/Access中國 ( 粵ICP備10043721號-1 )  

GMT+8, 2024-10-23 10:32 , Processed in 0.113577 second(s), 28 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表