Adicionado em: | 28/11/2010 |
Modificado em: | 28/11/2010 |
Tamanho: | Vazio |
Downloads: | 992 |
Retorna o nome do usuário e nome máquina
Saberexcel - Dicas microsoft Excel VBA
Estas macros com as declarações e funções retorna o nome do usuario e o nome do máquina
Option Explicit
Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Public Declare Function GetComputerName Lib "kernel32" _
Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Sub Teste_Usuario_host()
MsgBox "Usuário: [" & Nome_Usuario & "] e " & "Nome da Máquina [" & Nome_Maquina & " ]", _
vbInformation, "Saberexcel - o site das macros"
End Sub
Function Nome_Usuario() As String
Dim Buffer As String * 256
Dim BuffLen As Long
BuffLen = 256
If GetUserName(Buffer, BuffLen) Then _
Nome_Usuario = Left(Buffer, BuffLen - 1)
End Function
Function Nome_Maquina() As String
Dim Buffer As String * 256
Dim BuffLen As Long
Dim lngX As Long
Dim strCompName As String
BuffLen = 255
If GetComputerName(Buffer, BuffLen) Then _
Nome_Maquina = Left(Buffer, BuffLen)
End Function
Aprenda tudo sobre o Aplicativo Microsoft Excel VBA com Saberexcel
Adicionado em: | 27/11/2010 |
Modificado em: | 27/11/2010 |
Tamanho: | Vazio |
Downloads: | 993 |
Mostra os arquivos ativos na memória(Ram)
Saberexcel - dicas aplicativo microsoft excel vba macros
Estas declarações com a macro mostra todos os arquivos que estão
na memória RAM do seu computador, cria uma planilha com a relação
'****************** declarações*******
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 Load_Lista_Memoria()
Dim CurrWnd As Long
Dim Length As Long
Dim TaskName As String
Dim Parent As Long
i = 1
Sheets.Add 'adiciona uma nova planilha para receber os dados
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, 1).Value = TaskName
i = i + 1
End If
CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT)
DoEvents
Wend
'mensagem na planilha inserida
ActiveSheet.Range("E8").Value = "Nova Planilha inserida com a relação de todos ítens ativos na memória RAM"
Columns("A").AutoFit 'Ajusta a coluna A
End Sub
Aprenda tudo sobre o aplicativo Microsoft Excel VBA - com SaberExcel
Adquira já o Acesso Imediato
à Area de Membros
Aprenda Excel VBA com Simplicidade de
códigos e Eficácia, Escrevendo Menos e
Fazendo Mais.
'-------------------------------------'
Entrega Imediata:
+ 500 Video Aulas MS Excel VBA
+ 35.000 Planilhas Excel e VBA
+ Coleção 25.000 Macros MS Excel VBA
+ 141 Planilhas Instruções Loops
+ 341 Planilhas WorksheetFunctions(VBA)
+ 04 Módulos Como Fazer Excel VBA
+ Curso Completo MS Excel VBA
+ Planilhas Inteligentes
<script type="text/javascript"><!--
google_ad_client = "ca-pub-2317234650173689";
/* retangulo 336 x 280 */
google_ad_slot = "0315083363";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
Aprenda tudo sobre o Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Saberexcel,
Sobre as WorksheetFunctions Funções de Planilhas que retornam valores do VBA