View Single Post
  #19   Report Post  
Posted to microsoft.public.excel.programming
Geoff Geoff is offline
external usenet poster
 
Posts: 371
Default Taskbar and applications

Hi JLGWhiz
But thank you for staying with the issue. Thats what ngs are all about. I
really appreciate your efforts - thanks. Hopefully I'll get there in the end
:)

Regards

Geoff

"JLGWhiz" wrote:

Well, with that last explanation, I realized that I cannot supply the remedy
to your dilemma. Therefore, I exit. Good luck, Geoff.

"Geoff" wrote:

Hi Peter
The code, as is, raises the .chm but does not prevent multiple instances.
So perhaps to explain more fully what is happening:
there are two forms, each capable of calling the .chm from a cmdbutton
After the user has scrolled to whatever in they want in the .chm and return
to the form the .chm is sent to the taskbar. Now if the user leaves it there
and call the second form it is very easy to forget there is an instance of
the help file already raised.
What I can do at the moment with the posted code on the second click is
create a msgbox and also prevent another instance of the .chm. It would be
nice to Restore the .chm though instead. Ideally it would Restore to the
window state before minimising.
I have set the .chm default size and position in HTML Workshop to not
obscure the form which calls it thus the use of shell(....,1) or
vbNormalFocus.
Hope this explains better.

Geoff

"Peter T" wrote:

Hi Geoff,

You'd be much better off using the html help API, same code to open and/or
bring help to front in previous state (though need to be careful with
certain aspects to avoid crashes).

With Shell, you can open to correct page first time, thereafter all you can
do is bring it to front in previous maximized or restored state.

Public Declare Function FindWindowA Lib "user32" _
(ByVal lpClasssName As String, _
ByVal lpWindowName As String) As Long

Public Declare Function ShowWindow Lib "user32" _
(ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long

Sub test()
Dim hwnd As Long
Dim sHelp As String
Dim Res As Long

hwnd = FindWindowA("HH Parent", "help-file's main-window-caption")
If hwnd Then
ShowWindow hwnd, 1&
' occassionally might also need SetForegroundWindow hWnd (API not
shown)
Else

sHelp = "hh.exe " & "c:\xxx.chm"
'sHelp = sHelp & "::/" & "myHelpPage.html"

Res = Shell(sHelp, vbNormalFocus)

End If
End Sub

Regards,
Peter T

"Geoff" wrote in message
...
If the file name is xxx.chm then

AppActivate "xxx"
Windows("xxx.chm").WindowState = xlMaximized
returns 'subscript out of range'

using
Activewindow.WindowState = xlMaximized
activates the help file in the taskbar but does not restore it to its
original state.

Geoff


"JLGWhiz" wrote:

Go back to ActiveWindow without the typo

ActiveWindow.WindowState = xlMaximized

If that don't do it, then the window you want is not the active window.
But
you should be able to specify the window and use the xlMaximized
constant.

"Geoff" wrote:

Still no I'm afraid.


Geoff

"new_to_vba" wrote:

Geoff i am only new to this but have you tried

ActiveWindow.Visible=True

dont know if it will work but thought it might be worth a try.

"Geoff" wrote:

Ok that's got over the variable issue but its still not working.
As I say
focus is switched from Excel to the app but nothing happens beyond
that.

Geoff

"Gary Keramidas" wrote:

there's a typo,

ActiveWindow.WindowState =xlMaximized

--


Gary


"Geoff" wrote in message
...
That returns 'variable not defined'

Geoff

"JLGWhiz" wrote:

ActiveWindow.WindowState = xlMaximize

"Geoff" wrote:

I have created a Help file which is invoked from a
cmdbutton on a userform.
If the file is minimised and the user clicks the cmdbutton
again, the code
checks to see if it is already open and prevents multiple
instances. At
this
stage I could also generate a message to that effect.
However i thought it would be neat to emulate a click on
the taskbar icon
and make the .chm the top window again.
I have tried
AppActivate "xxx Analysis"
ActiveWindow.WindowState = vbNormalFocus
but while the file is activated it is not brought back up
again.
Can someone please point the way?

T.I.A.
Geoff