I have two monitors and the function returns 2 for me. I don't have a single
monitor system to test it on (sorry, I don't want to disconnect one monitor
because of the way I have my Desktop icons set up); but if you have a single
monitor system, and if the function returns 1, then that should mean the
code works correctly.
--
Rick (MVP - Excel)
"Robert Flanagan" wrote in message
...
Rick, thanks. I'll try it tomorrow (after I borrow the wife's monitor!).
If anyone has two monitors and can also test, please do so.
Bob
"Rick Rothstein" wrote in message
...
I'm pretty sure this will work. Put the following marked code in a Module
(Insert/Module from the VB editor's menu bar)...
'****************** Start Of Code ******************
Private Declare Function EnumDisplayMonitors Lib "user32.dll" _
(ByVal hdc As Long, ByRef lprcClip As Any, _
ByVal lpfnEnum As Long, ByVal dwData As Long) As Long
Private MonitorCount As Long
Public Function NumberOfMonitors()
MonitorCount = 0
EnumDisplayMonitors ByVal 0&, ByVal 0&, AddressOf MonitorEnumProc,
ByVal 0&
NumberOfMonitors = MonitorCount
End Function
Private Function MonitorEnumProc()
MonitorCount = MonitorCount + 1
MonitorEnumProc = 1
End Function
'****************** End Of Code ******************
And then simply call the NumberOfMonitors function from your own code.
For example...
Sub Test()
If NumberOfMonitors = 1 Then
MsgBox "There is only one monitor on this system."
Else
MsgBox "There are 2 or more monitors on this system"
End If
End Sub
--
Rick (MVP - Excel)
"Robert Flanagan" wrote in message
...
Is there a way to detect if a user has two or more monitors?
Bob