Microsoft Office Tutorials and References
In Depth Information
Windows API Calls
The ActivePrinter property of the Application object returns the name of the
active printer (and lets you change it), but there’s no direct way to determine what
printer driver or port is being used. That’s why this function may be useful.
Figure 11-21 shows a sample message box returned by this procedure.
Figure 11-21: Getting information about the active printer by using a Windows API call.
This example is available on the companion CD-ROM. The filename is printer info.
xlsm .
Determining video display information
The example in this section uses Windows API calls to determine a system’s current video mode
for the primary display monitor. If your application needs to display a certain amount of
information on one screen, knowing the display size helps you scale the text accordingly. In addition, the
code determines the number of monitors. If more than one monitor is installed, the procedure
reports the virtual screen size.
Declare PtrSafe Function GetSystemMetrics Lib “user32” _
(ByVal nIndex As Long) As Long
Public Const SM_CMONITORS = 80
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
Public Const SM_CXVIRTUALSCREEN = 78
Public Const SM_CYVIRTUALSCREEN = 79
Sub DisplayVideoInfo()
Dim numMonitors As Long
Dim vidWidth As Long, vidHeight As Long
Dim virtWidth As Long, virtHeight As Long
Dim Msg As String
numMonitors = GetSystemMetrics(SM_CMONITORS)
vidWidth = GetSystemMetrics(SM_CXSCREEN)
vidHeight = GetSystemMetrics(SM_CYSCREEN)
virtWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN)
virtHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN)
 
Search JabSto ::




Custom Search