Descricao: |
Saberexcel - o site de quem precisa aprender macros microsoft excel vba
 Estas declarações com a macro do aplicativo Microsoft excel vba, mostram todos os arquivos que estão na memória RAM do seu computador, cria uma planilha com a relação 'Incio do código
Private Declare Function GetWindow Lib "user32" _ (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetParent Lib "user32? (ByVal hwnd As Long) As Long" () Private Declare Function GetWindowTextLength Lib "user32" _ Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Declare Function GetWindowText Lib "user32" _ Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, _ ByVal cch As Long) As Long
Const GW_HWNDFIRST = 0 Const GW_HWNDNEXT = 2
Sub carregar_lista_arquivos_memoria() Dim CurrWnd As Long Dim Length As Long Dim TaskName As String Dim Parent As Long
i = 2 Sheets.Add 'insere uma nova planilha no livro On Error GoTo ErroSabx ActiveSheet.Name = "ARQUIVOS_MEMORIA_SABEREXCEL" twnd& = FindWindow("Shell_traywnd", vbNullString) CurrWnd = GetWindow(twnd, GW_HWNDFIRST)
While CurrWnd <> 0 Length = GetWindowTextLength(CurrWnd) TaskName = Space$(Length + 1) Length = GetWindowText(CurrWnd, TaskName, Length + 1) TaskName = Left$(TaskName, Len(TaskName) - 1)
If Length > 0 Then Cells(i, 2).Value = TaskName Cells(i, 2).Font.Size = 8 Cells(i, 2).Font.Name = "Consolas"
Cells(i, 1).Value = i & "º.)" Columns(2).AutoFit i = i + 1 End If CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT) DoEvents Wend Cells(1, 2).Value = "há [ " & i & " ] Arquivos na memória do seu computador" Cells(1, 2).Interior.ColorIndex = 35 Cells(1, 2).Font.ColorIndex = 5 Exit Sub
ErroSabx: MsgBox ("já existe uma planilha com esse nome, delete-a"), vbInformation, "Saberexcel - o site das macros" End Sub
Sub deletar_planilha_teste() On Error Resume Next Application.DisplayAlerts = False Sheets("ARQUIVOS_MEMORIA_SABEREXCEL").Delete End Sub
 Aprenda tudo sobre planilhas do Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Escola Saberexcel VBA Estudos® - Treinamentos com Macros, Fórmulas e Funções.

|