From: Peter on 27 Mar 2010 01:03 I jave a VBA application in Word that records sound using Sound recorder. UNFORTUNATELY Sound Recorder does not work correctrly in a machine which has more than 4 Gig of memory http://support.microsoft.com/default.aspx/kb/284893?p=1 Can I test the amount of memory using VBA in Word so that I can give the user an appropriate message? Any assistance very gratefully received, PeterEvans
From: Karl E. Peterson on 29 Mar 2010 18:49 Peter wrote: > Can I test the amount of memory using VBA in Word so that I can give the > user an appropriate message? Absolutely, using the GlobalMemoryStatusEx API. See: http://vb.mvps.org/samples/MemStatus -- ..NET: It's About Trust! http://vfred.mvps.org
From: Karl E. Peterson on 29 Mar 2010 18:56 Karl E. Peterson wrote: > Peter wrote: >> Can I test the amount of memory using VBA in Word so that I can give the >> user an appropriate message? > > Absolutely, using the GlobalMemoryStatusEx API. > > See: http://vb.mvps.org/samples/MemStatus That might be more confusing that it needs to be. Here's the "simple" answer (indented to highlight wordwrap): ' Win32 API Declarations Private Declare Function GlobalMemoryStatusEx Lib "kernel32" (lpBuffer As MEMORYSTATUSEX) As Long Private Type MEMORYSTATUSEX dwLength As Long dwMemoryLoad As Long ullTotalPhys As Currency ullAvailPhys As Currency ullTotalPageFile As Currency ullAvailPageFile As Currency ullTotalVirtual As Currency ullAvailVirtual As Currency ullAvailExtendedVirtual As Currency End Type Public Function InstalledMemory() As Variant Dim ms As MEMORYSTATUSEX Const CurrFactor As Long = 10000 ms.dwLength = Len(ms) Call GlobalMemoryStatusEx(ms) InstalledMemory = ms.ullTotalPhys * CurrFactor End Function Public Function Over4g() As Boolean Over4g = (InstalledMemory > (4 * 1024 ^ 3)) End Function Here, just calling Over4g() will tell you whether the machine has more than 4gb of installed RAM. -- ..NET: It's About Trust! http://vfred.mvps.org
|
Pages: 1 Prev: translation models Next: Using Sound Recorder in Word VBA SOMETIMES does not work |