If anyone has two monitors and can also test, please do so.
It works for me as expected with 4 monitors.
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
On Thu, 17 Sep 2009 23:48:56 -0400, "Robert Flanagan"
wrote:
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