Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default multiple monitors

Is there a way to detect if a user has two or more monitors?

Bob


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default 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







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default 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




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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








  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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?!!?!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening multiple templets in two monitors Morgan Excel Worksheet Functions 3 January 29th 10 04:42 PM
How do I view multiple worksheets on different monitors? S.M. Sullivan Setting up and Configuration of Excel 1 August 18th 09 09:36 PM
Multiple Instances for Multiple Monitors... Steve P[_2_] Excel Discussion (Misc queries) 4 November 19th 08 09:13 PM
Multiple Monitors Resolution & Userform JLGWhiz Excel Programming 0 March 1st 08 01:11 AM
Multiple instances across monitors? Paul Moloney Excel Discussion (Misc queries) 2 April 5th 05 12:05 PM


All times are GMT +1. The time now is 01:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"