- Excel VBA 質問スレ Part33
467 :デフォルトの名無しさん[sage]:2014/04/23(水) 12:31:02.08 ID:ZM+hJQpr - >>465
ほい PowerShellの出力をワートシートのA列に取り込むサンプル ' OpenProcess Declare PtrSafe Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Const SYNCHRONIZE = &H100000 ' WaitForSingleObject Declare PtrSafe Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Const WAIT_OBJECT_0 = &H0 ' CloseHandle Declare PtrSafe Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Sub sample2() Dim hProcess As Long, lret As Long lret = Shell("powershell ""Get-WmiObject -Class Win32_LogicalDisk|Clip""", vbHide) hProcess = OpenProcess(SYNCHRONIZE, 0, lret) Do Until WaitForSingleObject(hProcess, 100) = WAIT_OBJECT_0 DoEvents Loop lret = CloseHandle(hProcess) Cells(1, 1).Select ActiveSheet.Paste End Sub
|