![]() |
multiple monitors
Is there a way to detect if a user has two or more monitors?
Bob |
multiple monitors
The practical answer is no. However, threre is spyware, malware or whatever
you want to call it that has been developed that could possibly allow a hacker or even someone authorized access to determine a system's configuration. But I do not know of a way to do it with VBA. "Robert Flanagan" wrote in message ... Is there a way to detect if a user has two or more monitors? Bob |
multiple monitors
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 |
multiple monitors
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 |
multiple monitors
I see one of the statements word-wrapped. Here is the same code again, but
using a line continuation to make sure the statement doesn't word-wrap.... '****************** 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 ****************** -- Rick (MVP - Excel) "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 |
multiple monitors
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 |
multiple monitors
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 |
multiple monitors
works perfect if just one monitor. I would add a second but then the wife
couldn't see me behind the desk. Hmm...... Thanks, Bob "Rick Rothstein" wrote in message ... I see one of the statements word-wrapped. Here is the same code again, but using a line continuation to make sure the statement doesn't word-wrap.... '****************** 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 ****************** -- Rick (MVP - Excel) "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 |
multiple monitors
Thanks for the confirmation. Just one thing though... YOU HAVE 4
MONITORS?!!?! -- Rick (MVP - Excel) "Chip Pearson" wrote in message ... 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 |
multiple monitors
Rick, I got the impression that the OP was talking about remote access.
Your code appears to be for local access, or am I reading it wrong? "Rick Rothstein" wrote in message ... Thanks for the confirmation. Just one thing though... YOU HAVE 4 MONITORS?!!?! -- Rick (MVP - Excel) "Chip Pearson" wrote in message ... 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 |
multiple monitors
I just figured the OP was distributing his workbook to one or more people
and wanted to be able to check if these users had one or more monitor so he could adjust the functionality of his code around either hardware situation. -- Rick (MVP - Excel) "JLGWhiz" wrote in message ... Rick, I got the impression that the OP was talking about remote access. Your code appears to be for local access, or am I reading it wrong? "Rick Rothstein" wrote in message ... Thanks for the confirmation. Just one thing though... YOU HAVE 4 MONITORS?!!?! -- Rick (MVP - Excel) "Chip Pearson" wrote in message ... 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 |
multiple monitors
Thanks for the confirmation. Just one thing though... YOU HAVE 4
MONITORS?!!?! That's right, four 26" flat panels at 1920x1200, pumped by two NVidia GeForce 1GB cards. It is like sitting in mission control. Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Fri, 18 Sep 2009 09:38:50 -0400, "Rick Rothstein" wrote: Thanks for the confirmation. Just one thing though... YOU HAVE 4 MONITORS?!!?! |
multiple monitors
Wow! That is impressive. I have a 26" and a 19" and everything I need to do
fits on those two screens... I can't imagine trying to make use of 2 more large screens. -- Rick (MVP - Excel) "Chip Pearson" wrote in message ... Thanks for the confirmation. Just one thing though... YOU HAVE 4 MONITORS?!!?! That's right, four 26" flat panels at 1920x1200, pumped by two NVidia GeForce 1GB cards. It is like sitting in mission control. Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Fri, 18 Sep 2009 09:38:50 -0400, "Rick Rothstein" wrote: Thanks for the confirmation. Just one thing though... YOU HAVE 4 MONITORS?!!?! |
All times are GMT +1. The time now is 07:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com