Saberexcel o site das macros
Estas declarações macros e funções do aplicativo Microsoft Excel VBA, mostram o total de memória
Option Explicit
Declare Function GetCommandLine Lib "kernel32" _
Alias "GetCommandLineA" () As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(lpvDest As Any, lpvSource As Any, ByVal NumBytes As Long)
Sub TestCommand()
MsgBox VBACommand
MsgBox VBACommand2
End Sub
Function VBACommand() As String
Dim Buffer() As Byte
Dim Addr As Long
Dim sTemp As String
Dim i As Long
Const BufferLen = 256
ReDim Buffer(0 To BufferLen - 1)
Addr = GetCommandLine()
CopyMemory Buffer(0), ByVal Addr, BufferLen
'converte caracter ANSI em string para UNICODE
sTemp = StrConv(Buffer(), vbUnicode)
'truncar se for byte nulo
i = InStr(sTemp, Chr$(0))
If i > 0 Then
VBACommand = Left$(sTemp, i - 1)
Else
VBACommand = sTemp & "….."
End If
End Function
'---------------------------------'
Function VBACommand2() As String
Dim Buffer As String
Dim Addr As Long
Const BufferLen = 256
Buffer = String$(BufferLen, 0)
Addr = GetCommandLine()
CopyMemory ByVal Buffer, ByVal Addr, BufferLen
'nao precisa converter ANSI / Unicode
VBACommand2 = Left$(Buffer, InStr(1, Buffer, Chr$(0)) - 1)
End Function
Aprenda tudo sobre o Aplicativo Microsoft Excel VBA com Saberexcel