ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] Application.MemoryFree EXCEL 2007µLªk°õ¦æ

[µo°Ý] Application.MemoryFree EXCEL 2007µLªk°õ¦æ

EXCEL 2003 VBA ¤U¦C»y¥y¥i¥H°õ¦æ
Application.MemoryFree
Application.MemoryTotal
Application.MemoryUsed

¥i¬O¦bEXCEL 2007«oµLªk°õ¦æ(³Q¨ú®ø¤F?)
¦³¤°»ò¨ç¼Æ¥i¥H´À¥N?
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

DOS ®É´Á¼g¹L FORTRAN¡A«á¨Ó°±¤F15¦~¨S¦³Ä~Äò¼g¡A³Ìªñ¤~¶}©l¾Ç Excel VBA»yªk¡A¤]¥¿¦bºN¯Á¤¤¡A©Ò¥H§Ú±`¨Ó³o¸Ì³}¡C
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¦^´_ 6# ML089
¤§«e§Ú¥u±µÄ²¨ì C/C++ À³¥Î³nÅ鼶¼g¤è­±¡A¬Æ¤ÖÂyÄá Excel¡A
©Ò¥H§A·|µoı¦b Excel »yªk³B²z¤W±`±`»Ý­n¨D§U¡AÁöµM³£¬O
»y¨¥¡A¦ý¬O¦b¸ê®Æ¼h³B²z¤WÁÙ¬O¦³¨Ç·Lªº°Ï§Oªº¡C
¤@¶}©l¬Ý¨ì§Aªºµo¤å¡A§Ú¤]¬O¤£Â_¦a¤Wºô·j´M¬ÛÃö¸ê®Æ¡A
µ²ªG³£¸ò§A 1# ¡B2# ªº¤º®e¤@¼Ë¡A©Ò¥H§Ú¤~»¡¥L­Ì«D±`¥i·R¡C

TOP

¦^´_ 5# c_c_lai

¥»¥H¬° 2003ª©ªºVBA¦b2007ª©¤@©w¥i¥H¨Ï¥Î¡A­ì¨Ó·L³n¨º»ò "¥i·R" ÁÙ·|¸ò§Ú­Ì¶}¶}¤pª±¯º¬G·N§â¥\¯à¨ú®ø±¼¡C

§Ú¥»¨Ó¬O·QºÊ´úVBAµ{¦¡¶}°}¦C®É·|¥Î±¼¦h¤Ö°O¾ÐÅé¡A·¥­­¬O¥i¥H¶}¦h¤Ö°O¾ÐÅé¤j¤p¡A¥H§QŪ¨ú¤j«¬TXTÀɮɭn¦p¦óŪ¤J³Ì¤j¶q¨Ó¥[³tµ{¦¡°õ¦æ¡C

¤£ª¾§A¦³³o¤è­±ªº¸ê®Æ¥i¥H´£¨Ñ°Ñ¦Ò¶Ü?
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¦^´_ 1# ML089
«Ü¿ò¾Ñ¡A³o¨Ç¥\¯à³£³Q·L³nÁôÂð_¨Ó¤F¡C
³o¥ç¬O¥L­Ì¥i·Rªº¦a¤è¡C

TOP

ªí¸û¤@¤U #1 ¤Î #2 ©ÒÅã¥Üªº°O¾ÐÅ餺®e



ScreenClip1.png (19.87 KB)

ScreenClip1.png

{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

«e­±¬O2003ª©¥i¥H°õ¦æ¡A2007ª©¤£¯à
¤U­±¬O2003 /2007ª©³£¥i¥H¥Î
¦ý¨â­Ó¹ï°O¾Ðªºªí¹F¤£¦P

¦p¦ó¡G ±q Excel 2000 ¤¤ªº Windows API ¨ú±o Windows ªºª¬ºA¸ê°T¨Ó·½ URL¡G http://support.microsoft.com/kb/213267
¦p¦ó¡G ±q Excel 2000 ¤¤ªº Windows API ¨ú±o Windows  ªºª¬ºA¸ê°T
¦b Microsoft Excel ¥i¥H¥Hµ{¦¡³]­pªº¤è¦¡¨ú±o¨t²Îª¬ºA¸ê°T¡A¨ÃÅã¥Ü¦b¤u§@ªí¤¤¡C¥»¤å±N³v¨B´£¨Ñ Microsoft Visual Basic for Applications ½d¨Ò·|Åã¥Ü¤U¦Cªº¸ê°T¡AÂǥѨϥΠWindows API ¨ç¦¡ªº Sub µ{§Ç¡G
        * GetVersionEx API ¨ç¦¡ªº Windows ª©¥»¸¹½X¡C
        * ¨ã¦³ GetSystemInfo API ¨ç¦¡ªº CPU ³B²z¾¹«¬§O¡C
        * ¨Ï¥Î GlobalMemoryStatus API ¨ç¦¡ªº¥i¥Î°O¾ÐÅé¼Æ¶q¡C

­Y­n¨ú±o Windows  ª¬ºA¸ê°Tªº½d¨Òµ{¦¡½XMicrosoft ·|´£¨Ñµ{¦¡³]­p½d¨Ò¶È¨Ñ»¡©ú¡A¤£°µ¥ô¦ó©ú¥Ü©ÎÀq¥Üªº«OÃÒ¡A¨ä¤¤¥]¬A¦ý¤£¬O­­©ó¾A°â©Ê¥H¤Î¾A¦X¬Y¯S©w¥Î³~¤§Àq¥Ü¾á«O³d¥ô¡C¥»¤å°²³]±z¤w¼ô±x§Ú­Ì©Ò¥Ü½dªºµ{¦¡³]­p»y¨¥¥H¤Î¥Î¨Ó«Ø¥ß©M°»¿ùµ{§Çªº¤u¨ã¡CMicrosoft §Þ³N¤ä´©¤uµ{®v¥i¥H¨ó§U¸ÑÄÀ¯S©wµ{§Çªº¥\¯à¡A¦ý¥¦­Ì¤£·|­×§ï³o¨Ç½d¨Ò¥H´£¨Ñªþ¥[¥\¯à©Î«Øºcµ{§Ç¨Óº¡¨¬±zªº¯S©w»Ý¨D¡C
¦pªG±z¦³­­¨îªºµ{¦¡³]­p¸gÅç¡A±z¥i¯à·Q­n³sµ¸·L³n»{ÃÒ¹Ù¦ñ ¡v ©Î ¡u Microsoft ¿Ô¸ßªA°È¡C¦p»Ý¸Ô²Ó¸ê°T¡A½Ð³y³X¤U¦C Microsoft ºô¯¸¨ú±o¡G

Microsoft »{ÃÒ¦X§@¹Ù¦ñ- https://partner.microsoft.com/global/30000104

Microsoft ¿Ô¸ßªA°È- http://support.microsoft.com/gp/advisoryservice

¦p»Ý¦³Ãö¥i¥Îªº¤ä´©¿ï¶µ¡A¥H¤Î¦³Ãö¦p¦ó³sµ¸ Microsoft ªº¸Ô²Ó¸ê°T¡A½Ð³y³X¤U¦C Microsoft ºô¯¸¡G http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS ­Y­n¨Ï¥Î Windows API ©I¥s¡A¥H¨ú±o Windows ª¬ºA¸ê°T¡A½Ð¨Ì·Ó¤U¦C¨BÆJ°õ¦æ¡G
        1. ±Ò°Ê Microsoft Excel¡AµM«á«Ø¥ß·sªº¬¡­¶Ã¯¡C
        2. ¦b [¤u¨ã] ¥\¯àªí¤W«ü¦V [¥¨¶°¡AµM«á«ö¤@¤U [ Visual Basic ½s¿è¾¹] (©Î«ö¤U ALT + F11)¡C
        3. «ö¤@¤U [´¡¤J] ¥\¯àªíªº [¼Ò²Õ]¡C
        4. ¦b¼Ò²Õ¤u§@ªí¤¤¡A¿é¤J¤U¦Cµ{¦¡½X¡G
Option Explicit

Type SYSTEM_INFO
    dwOemID As Long
    dwPageSize As Long
    lpMinimumApplicationAddress As Long
    lpMaximumApplicationAddress As Long
    dwActiveProcessorMask As Long
    dwNumberOrfProcessors As Long
    dwProcessorType As Long
    dwAllocationGranularity As Long
    dwReserved As Long
End Type

Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type

Type MEMORYSTATUS
    dwLength As Long
    dwMemoryLoad As Long
    dwTotalPhys As Long
    dwAvailPhys As Long
    dwTotalPageFile As Long
    dwAvailPageFile As Long
    dwTotalVirtual As Long
    dwAvailVirtual As Long
End Type

'The following three Declare lines must be each entered on a single
'line.

Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
             (LpVersionInformation As OSVERSIONINFO) As Long
Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As _
            MEMORYSTATUS)
Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As _
              SYSTEM_INFO)

Public Const PROCESSOR_INTEL_386 = 386
Public Const PROCESSOR_INTEL_486 = 486
Public Const PROCESSOR_INTEL_PENTIUM = 586
Public Const PROCESSOR_MIPS_R4000 = 4000
Public Const PROCESSOR_ALPHA_21064 = 21064

Sub SystemInformation()
Dim msg As String         ' Status information.
Dim NewLine As String     ' New-line.
Dim ret As Integer        ' OS Information
Dim ver_major As Integer  ' OS Version
Dim ver_minor As Integer  ' Minor Os Version
Dim Build As Long         ' OS Build

      NewLine = Chr(13) + Chr(10)  ' New-line.
      ' Get operating system and version.
      Dim verinfo As OSVERSIONINFO
      verinfo.dwOSVersionInfoSize = Len(verinfo)
      ret = GetVersionEx(verinfo)
      If ret = 0 Then
          MsgBox "Error Getting Version Information"
          End
      End If

      Select Case verinfo.dwPlatformId
          Case 0
              msg = msg + "Windows 32s "
          Case 1
              msg = msg + "Windows 95/98 "
          Case 2
              msg = msg + "Windows NT/2000 "
      End Select

      ver_major = verinfo.dwMajorVersion
      ver_minor = verinfo.dwMinorVersion
      Build = verinfo.dwBuildNumber
      msg = msg & ver_major & "." & ver_minor
      msg = msg & " (Build " & Build & ")" & NewLine & NewLine

      ' Get CPU type and operating mode.
      Dim sysinfo As SYSTEM_INFO
      GetSystemInfo sysinfo
      msg = msg + "CPU: "
      Select Case sysinfo.dwProcessorType
          Case PROCESSOR_INTEL_386
              msg = msg + "Intel 386" + NewLine
          Case PROCESSOR_INTEL_486
              msg = msg + "Intel 486" + NewLine
          Case PROCESSOR_INTEL_PENTIUM
              msg = msg + "Intel Pentium" + NewLine
          Case PROCESSOR_MIPS_R4000
              msg = msg + "MIPS R4000" + NewLine
          Case PROCESSOR_ALPHA_21064
              msg = msg + "DEC Alpha 21064" + NewLine
          Case Else
              msg = msg + "(unknown)" + NewLine
      End Select

      msg = msg + NewLine

      ' Get free memory.
      Dim memsts As MEMORYSTATUS
      Dim memory As Long
      GlobalMemoryStatus memsts
      memory = memsts.dwTotalPhys
      msg = msg + "Total Physical Memory: "
      msg = msg + Format(memory \ 1024, "###,###,###") + "K" + NewLine
      memory = memsts.dwAvailPhys
      msg = msg + "Available Physical Memory: "
      msg = msg + Format(memory \ 1024, "###,###,###") + "K" + NewLine
      memory = memsts.dwTotalVirtual
      msg = msg + "Total Virtual Memory: "
      msg = msg + Format(memory \ 1024, "###,###,###") + "K" + NewLine
      memory = memsts.dwAvailVirtual
      msg = msg + "Available Virtual Memory: "
      msg = msg + Format(memory \ 1024, "###,###,###") + "K" + NewLine

      MsgBox msg, vbOKOnly, "System Info"
End Sub
                                       

        5. ¦b [¤u¨ã] ¥\¯àªí¤W«ö¤@¤U [¥¨¶°¡AµM«á«ö¤@¤U [¥¨¶°¡C
        6. «ö¤@¤UÄÝ©Ê¡A¡AµM«á«ö¤@¤U [°õ¦æ¡C

¦¹¥¨¶°·|¶Ç¦^±zªº¨t²Î¸ê°T·|Åã¥Ü¤@­Ó°T®§¤è¶ô¡C



¿Ã¹õÂ^¨ú
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

ºô¸ô§ä¨ì¨â½g¸ê®Æ¡A¦n¹³¨S¦³¤H¹ï¦¹¦³¿³½ì

2003ª©ªºÀ³¥Î

MemoryFree Property [Excel 2003 VBA Language Reference]

¨Ó·½ URL¡G http://msdn.microsoft.com/en-us/library/office/aa175728(v=office.11).aspx
MemoryFree Property [Excel 2003 VBA Language Reference]
Office 2003

This topic has not yet been rated - Rate this topic

Returns the amount of memory that's still available for Microsoft Excel to use, in bytes. Read-only Long.

Example

This example displays a message box showing the number of free bytes.

MsgBox "Microsoft Excel has " & _    Application.MemoryFree & " bytes free"

Sub version()

    Dim wrkbk As Variant
    Dim User As Variant
    Dim Vers As Variant
    Dim memfree As Variant
    Dim memtotal As Variant
    Dim memused As Variant
    On Error Resume Next
    wrkbk = Application.ActiveWorkbook.Name
    User = Application.UserName
    Vers = Application.version
    memfree = Application.MemoryFree 'EXCEL 2003 ONLY USE
    memtotal = Application.MemoryTotal 'EXCEL 2003 ONLY USE
    memused = Application.MemoryUsed 'EXCEL 2003 ONLY USE

    MsgBox _
            "Memory Total: " & memtotal & Chr(13) & _
            "Memory Used:  " & memused & Chr(13) & _
            "Memory Free:  " & memfree & Chr(13) & _
            Chr(13) & _
            "Name of workbook: " & wrkbk & Chr(13) & _
            "Name of User: " & User & Chr(13) & _
            "Version of VBA: " & Vers
End Sub

¿Ã¹õÂ^¨ú
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

        ÀR«ä¦Û¦b : ¡i®É¶¡¦pÆp¥Û¡j®É¶¡¹ï¤@­Ó¦³´¼¼zªº¤H¦Ó¨¥¡A´N¦pÆp¥Û¯ë¬Ã¶Q¡F¦ý¹ï·M¤H¨Ó»¡¡A«o¹³¬O¤@§âªd¤g¡A¤@ÂI»ù­È¤]¨S¦³¡C
ªð¦^¦Cªí ¤W¤@¥DÃD