Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Show every instance of Word?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ed - 09 Nov 2005 18:26 GMT
Every now and then, I get a flash of a small Word window that looks like
it's left over from running a macro program (in the program, I deliberately
set the Word window to about 3 inches square and parked it off to the side).
Is there a way to get a Word macro to show me every instance of Word, even
if not visible?

As a side question, would it be possible for this instance of Word to get
"caught" somewhere, and persist or reopen after Restarts and Shut Downs?  I
am using Word 2000 and Windows 2000.

Ed
Karl E. Peterson - 09 Nov 2005 18:42 GMT
> Every now and then, I get a flash of a small Word window that looks
> like it's left over from running a macro program (in the program, I
> deliberately set the Word window to about 3 inches square and parked
> it off to the side). Is there a way to get a Word macro to show me
> every instance of Word, even if not visible?

Sure.  Will take a bit of hand-tuning, but the basic idea would be to:

*** call EnumWindows,

  http://vb.mvps.org/samples/FindPart

*** watch for those with a classname of "OpusApp",

  Private Declare Function GetClassname Lib "user32" Alias "GetClassNameA" (ByVal
hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

  Private Function Classname(ByVal hWnd As Long) As String
     Dim nRet As Long
     Dim Class As String
     Const MaxLen As Long = 256

     ' Retrieve classname of passed window.
     Class = String$(MaxLen, 0)
     nRet = GetClassname(hWnd, Class, MaxLen)
     If nRet Then Classname = Left$(Class, nRet)
  End Function

*** call ShowWindow to make visible.

  Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
  Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal
nCmdShow As Long) As Long

  Private Const SW_HIDE = 0
  Private Const SW_SHOW = 5

  Public Function WindowVisible(ByVal hWnd As Long, Optional NewValue) As Boolean
     ' Attempt to affirm, if user specified a new setting.
     If Not IsMissing(NewValue) Then
        If CBool(NewValue) Then
           Call ShowWindow(hWnd, SW_SHOW)
        Else
           Call ShowWindow(hWnd, SW_HIDE)
        End If
     End If
     ' Return current visibility.
     WindowVisible = IsWindowVisible(hWnd)
  End Function

> As a side question, would it be possible for this instance of Word to
> get "caught" somewhere, and persist or reopen after Restarts and Shut
> Downs?  I am using Word 2000 and Windows 2000.

Sounds unlikely to the point of impossible, no.
--
Working Without a .NET?
http://classicvb.org/petition
Ed - 09 Nov 2005 20:49 GMT
I take it this would be better off in a VB6 app than a Word macro?

> > Every now and then, I get a flash of a small Word window that looks
> > like it's left over from running a macro program (in the program, I
[quoted text clipped - 54 lines]
> Working Without a .NET?
> http://classicvb.org/petition
Karl E. Peterson - 09 Nov 2005 21:37 GMT
> I take it this would be better off in a VB6 app than a Word macro?

No, not at all.  Would work just fine, in either place.
--
Working Without a .NET?
http://classicvb.org/petition

>>> Every now and then, I get a flash of a small Word window that looks
>>> like it's left over from running a macro program (in the program, I
[quoted text clipped - 56 lines]
>> Working Without a .NET?
>> http://classicvb.org/petition
Ed - 09 Nov 2005 21:41 GMT
Thanks, Karl.  I'll have to work with this a bit to make sure I've got it
right.
Ed

> > I take it this would be better off in a VB6 app than a Word macro?
>
[quoted text clipped - 63 lines]
> >> Working Without a .NET?
> >> http://classicvb.org/petition
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.