Moderatori: Anthony47, Flash30005
Sub runAttrib()
myDir = "D:\Music\" '<< Drive & directory
Close #1
Open "C:\PROVA\myPippoBat.bat" For Output As #1
Print #1, "C:\Windows\System32\attrib.exe " & myDir & "*.mp3 /s >C:\PROVA\pippop.txt" '<<< *.ext
Close #1
myPid = Shell("C:\PROVA\myPippoBat.bat")
Application.Wait (Now + TimeValue("0:00:02"))
myTim = Timer
Do While IsProcessRunning("attrib.exe")
DoEvents: DoEvents: Loop
'MsgBox (Timer - myTim)
End Sub
Private Function IsProcessRunning(ByVal ProcName As String) As Boolean
Dim objWMIService, objProcess, colProcess
Dim strComputer, strList
'
strComputer = "."
'
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")
For Each objProcess In colProcess
If CBool(InStr(1, objProcess.Name, ProcName, vbTextCompare)) Then
IsProcessRunning = True
Exit Function
End If
DoEvents
Next
End Function
A D:\Music\09_-_wanderlust_-_sailing_to_philadelphia.mp3
Sub ListProcedures()
'
Dim VBCodeMod
Dim StartLine As Long
Dim Msg As String
Dim ProcName As String
Dim VBComp
Dim ModName As String
myWKBook = ActiveWorkbook.Name
For Each VBComp In ActiveWorkbook.VBProject.VBComponents
ModName = VBComp.Name
myMod = VBComp.Type '1=modulo; 100=Foglio /Thisworkbook; 3=Userform; lista non esaustiva
'
Set VBCodeMod = ActiveWorkbook.VBProject.VBComponents(ModName).CodeModule
With VBCodeMod
StartLine = .CountOfDeclarationLines + 1
Do Until StartLine >= .CountOfLines
myPROCEDURE = .ProcOfLine(StartLine, 0)
myHead = VBCodeMod.Lines(StartLine, 1)
' Msg = Msg & .ProcOfLine(StartLine, 0) & vbCrLf
StartLine = StartLine + .ProcCountLines(.ProcOfLine(StartLine, 0), 0)
'>>>>>>
'>>>>>>
Loop
End With
Next VBComp
'MsgBox Msg
End Sub
myDate = FileDateTime("FullPath&Name")
myComputer = Environ("ComputerName")
Rimane il problema di scnsionare tutti i drive presenti in un Pc, ma qui non ho mai fatto niente.
Option Explicit
Public mNome As String, mPercorso As String, mBat As String, mPid
Sub Cerca_File_Excel()
mPercorso = "D:\Temp\" ' <<=== Percorso sul qual cercare i file
Close #1
mBat = "D:\Temp\File_sul_PC.bat"
Open mBat For Output As #1
mNome = " D:\Temp\Elenco_File.txt" ' <<=== Nome del file cotentnete tutti i file trovati
Print #1, "C:\Windows\System32\attrib.exe " & mPercorso & "*.xls /s >" & mNome
Close #1
mPid = Shell(mBat)
Application.Wait (Now + TimeValue("0:00:02"))
Do While IsProcessRunning("attrib.exe")
DoEvents
Loop
MsgBox "Elaborazione effettuata." & vbCrLf & vbCrLf & "I dati sono stati scrittti in '" & mNome & "'"
End Sub
Private Function IsProcessRunning(ByVal ProcName As String) As Boolean
Dim objWMIService, objProcess, colProcess
Dim strComputer, strList
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")
For Each objProcess In colProcess
If CBool(InStr(1, objProcess.Name, ProcName, vbTextCompare)) Then
IsProcessRunning = True
Exit Function
End If
DoEvents
Next
End Function
Sub Elenco_Moduli()
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim Ws_In As Worksheet, Ws_Out As Worksheet, I As Long, J As Long, UR As Long, Totale As Long
Dim mNome As String
Set Ws_In = ActiveWorkbook.Worksheets("NomiFile")
Set Ws_Out = ActiveWorkbook.Worksheets("ModuliTrovati")
Ws_Out.Select
If Ws_Out.Range("A1") = "" Then
Ws_Out.Range("A1") = "Nome file"
Ws_Out.Range("B1") = "Nome modulo"
Ws_Out.Range("C1") = "Numero del 'Tipo'"
Ws_Out.Range("D1") = "Descrizione del 'Tipo'"
Ws_Out.Columns("A:D").AutoFit
End If
Ws_Out.Range("A2:D" & Rows.Count).ClearContents
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Totale = 0
UR = Ws_In.Range("A" & Rows.Count).End(xlUp).Row
J = 2
For I = 2 To UR
mNome = Ws_In.Cells(I, 1)
Workbooks.Open FileName:=mNome, Origin:=xlWindows
Windows(Ws_In.Cells(I, 2).Value).Activate
Set VBProj = ActiveWorkbook.VBProject
For Each VBComp In VBProj.VBComponents
If VBComp.Type = 1 Then ' con = 1 vengono scritti solo i Moduli
Totale = Totale + 1
Ws_Out.Cells(J, 1).Value = mNome
Ws_Out.Cells(J, 2).Value = VBComp.Name
Ws_Out.Cells(J, 3).Value = VBComp.Type
Ws_Out.Cells(J, 4).Value = ComponentTypeToString(VBComp.Type)
J = J + 1
End If
Next VBComp
ActiveWindow.Close
Next I
Ws_Out.Columns(1).AutoFit
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "File elaborati: '" & I - 2 & "'" & vbCrLf & vbCrLf & "Moduli trovati: '" & Totale & "'"
End Sub
Set VBAEditor = Application.VBE
Modulo Nome del Modulo contenente la macro
Macro Name Il titolo della macro
Type Il tipo di modulo: 1=Standard; 100=Foglio; 3=Userform Questi i piu' comuni (ELENCO INCOMPLETO)
Date La data di aggiornamento del file
Computer Il Computername su cui viene eseguita la raccolta
First Line La prima riga della macro (ma tramite la variabile myHLine si puo' impostare anche una riga diversa, es 2 se si sa che in riga 2 c' e' una particolare info)
File Path & Filename
For Each VBComp In ActiveWorkbook.VBProject.VBComponents
Workbooks.Open myCFile, 0, True
'Salva info di macro in Foglio2:
myNRow = ProcList.Cells(ProcList.Rows.Count, 7).End(xlUp).Row + 1 '<<< QUESTA RIGA
Sub TestThisWorkbook()
Dim sourceBook As Workbook
Dim destinationBook As Workbook
Dim codeFromSource As String
Set sourceBook = ThisWorkbook
With sourceBook.VBProject.VBComponents("ThisWorkbook").CodeModule
codeFromSource = .Lines(1, .CountOfLines)
End With
Cells(1, 1) = codeFromSource
End Sub
Sub TestUserForm1()
Dim sourceBook As Workbook
Dim destinationBook As Workbook
Dim codeFromSource As String
Set sourceBook = ThisWorkbook
With sourceBook.VBProject.VBComponents("UserForm1").CodeModule
codeFromSource = .Lines(1, .CountOfLines)
End With
Cells(1, 1) = codeFromSource
End Sub
Torna a Applicazioni Office Windows
Macro modifica date scelta periodo Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 11 |
Inserire dati filtrati da 2 file ad un terzo file Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 14 |
Supporto per sviluppo macro VBA Ordinare per data Autore: Carletto Ribolla |
Forum: Applicazioni Office Windows Risposte: 3 |
Visitano il forum: Nessuno e 12 ospiti