PPT2000: Sample Code to Determine the Windows Display Resolution (240386)



The information in this article applies to:

  • Microsoft PowerPoint 2000

This article was previously published under Q240386

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. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements.

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 how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

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


Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbcode kbhowto kbinfo kbProgramming KB240386