Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di Gach74
    Registrato dal
    Nov 2009
    Messaggi
    21

    PROBLEMA CON OGGETTO Application.FileSearch

    Ciao a tutti, io ho un problema con questo codice:

    Sub prova()
    With Application.FileSearch
    .LookIn = "c:\" 'look in the folder browsed to
    .FileType = msoFileTypeAllFiles 'get all files
    .SearchSubFolders = False 'search sub directories
    .Execute 'run the search

    For x = 1 To .FoundFiles.Count 'for each file found, by the count (or index)
    i = x 'make the variable i = x
    If x > 60000 Then 'if there happens to be more than multipls of 60,000 files, then add a new sheet
    i = x - 60000 'set i to the right number for row placement below
    Set wsNew = wbNew.Sheets.Add(after:=Sheets(wsNew.Index))
    With wsNew.Range("A1:F1")
    .Value = Array("File", "Parent Folder", "Full Path", "Modified Date", _
    "Last Accessed", "Size")
    .Interior.ColorIndex = 7
    .Font.Bold = True
    .Font.Size = 12
    End With

    End If
    On Error GoTo Skip 'in the event of a permissions error

    Set objFile = objFSO.GetFile(.FoundFiles(x)) 'set the object to get it's properties
    With wsNew.Cells(1, 1) 'populate the next row with the variable data
    .Offset(i, 0) = objFile.Name
    .Offset(i, 1) = Format(objFile.Size, "0,000") & " KB"
    .Offset(i, 2) = objFile.DateLastModified
    .Offset(i, 3) = objFile.DateLastAccessed
    .Offset(i, 4) = objFile.DateCreated
    .Offset(i, 5) = objFile.Path

    End With
    ' Next objFile
    Skip:
    'this is in case a Permission denied error comes up or an unforeseen error
    'Do nothing, just go to next file
    Next x
    wsNew.Columns("A:F").AutoFit

    End With
    End Sub

    Quando cerco di mandarlo in esecuzione di ferma sull'APPLICATION.FILESEARCH e mi dice:

    "Errore di run-time "445"

    Azione non valida per l'oggetto"

    ho provato ad andare sul sito microsoft ma non trovo nulla di errato nella sintassi.

    Grazie per l'aiuto
    GACH 74
    H.M. Is The Law

  2. #2
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,466

    Moderazione

    Linguaggio?
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

  3. #3
    Utente di HTML.it L'avatar di Gach74
    Registrato dal
    Nov 2009
    Messaggi
    21
    OFFICE 2007 VB
    GACH 74
    H.M. Is The Law

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.