PPT2000: Sample Code to Determine the Windows Display Resolution

ID: Q240386


The information in this article applies to:
  • Microsoft PowerPoint 2000


SUMMARY

This article contains a sample Microsoft Visual Basic for Applications macro (Sub procedure) that demonstrates how to determine the current display resolution.


MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp

Sample Visual Basic for Applications Procedure


Option Explicit

Type RECT
   x1 As Long
   y1 As Long
   x2 As Long
   y2 As Long
End Type

' NOTE: The following declare statements are case sensitive.

Declare Function GetDesktopWindow Lib "User32" () As Long
Declare Function GetWindowRect Lib "User32" _
          (ByVal hWnd As Long, rectangle As RECT) As Long

Sub resolution()
   MsgBox GetScreenResolution
End Sub

Function GetScreenResolution() As String
   Dim R As RECT
   Dim hWnd As Long
   Dim RetVal As Long

   hWnd = GetDesktopWindow()
   RetVal = GetWindowRect(hWnd, R)

   GetScreenResolution = (R.x2 - R.x1) & "x" & (R.y2 - R.y1)

End Function 


REFERENCES

For more information about creating Visual Basic for Applications macros, click Microsoft PowerPoint Help on the Help menu, type Create a macro in Visual Basic Editor in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For more information about how to run a macro, click Microsoft PowerPoint Help on the Help menu, type Run a macro in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For more information about using the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

Q212536 OFF2000: How to Run Sample Code from Knowledge Base Articles

Additional query words: 2000 ppt2000 ppt2k 2k ppt9 9.0 kbmacro vba vbe

Keywords : kbcode kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto kbinfo


Last Reviewed: September 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.