Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
Sorry,
Application.WindowState = xlMaximize "Geoff" wrote: 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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
isn't there still supposed to be a d on the end?
Application.WindowState = xlMaximized -- Gary "JLGWhiz" wrote in message ... Sorry, Application.WindowState = xlMaximize "Geoff" wrote: 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 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
It is not an execel application though and xlmaximize is not recognised
Here is my code Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _ ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) As Long Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal lnghProcess As Long, _ lpExitCode As Long) As Long Private Const PROCESS_ALL_ACCESS = &H1F0FFF Private RetVal As Long Public Function ShlProc_IsRunning(ShellReturnValue As Long) As Boolean Dim lnghProcess As Long Dim lExitCode As Long Dim lRet As Long lnghProcess = OpenProcess(PROCESS_ALL_ACCESS, 0&, ShellReturnValue) If lnghProcess < 0 Then GetExitCodeProcess lnghProcess, lExitCode '''test if help file is running If lExitCode < 0 Then ShlProc_IsRunning = True Else ShlProc_IsRunning = False End If End If End Function Sub ShellTester() If ShlProc_IsRunning(RetVal) = False Then '''show help file if not already open On Error Resume Next RetVal = Shell("hh.exe c:\xxx.chm", 1) On Error GoTo 0 Else AppActivate "Vehicle Performance Analysis" Application.WindowState = xlMaximize '''msgbox "Help File is already loaded" End If End Sub Geoff "JLGWhiz" wrote: Sorry, Application.WindowState = xlMaximize "Geoff" wrote: 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 |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
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 |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
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 |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
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 |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
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 |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
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 |
#13
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
Geoff, don't know if this will help, but I got it out of the VBA help files.
Shell Function Example This example uses the Shell function to run an application specified by the user. On the MacIntosh, the default drive name is €œHD€ and portions of the pathname are separated by colons instead of backslashes. Similarly, you would specify Macintosh folders instead of \Windows. ' Specifying 1 as the second argument opens the application in ' normal size and gives it the focus. Dim RetVal RetVal = Shell("C:\WINDOWS\CALC.EXE", 1) ' Run Calculator. windowstyle - Optional. Variant (Integer) corresponding to the style of the window in which the program is to be run. If windowstyle is omitted, the program is started minimized with focus. On the Macintosh (System 7.0 or later), windowstyle only determines whether or not the application gets the focus when it is run. "Geoff" wrote: 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 |
#14
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
Hi
In post #6 of this thread you can find that snippet. What my code does in this case is open the help.chm file, note its id and check if it's still running should the cmdbutton be used again. My problem is in wanting to do something with that second press - I can either give a message or Restore the window assuming it has been minimised. So the snippet gets part way. Thanks for your endeavours so far, I appreciate the help in a difficult area. Geoff "JLGWhiz" wrote: Geoff, don't know if this will help, but I got it out of the VBA help files. Shell Function Example This example uses the Shell function to run an application specified by the user. On the MacIntosh, the default drive name is €œHD€ and portions of the pathname are separated by colons instead of backslashes. Similarly, you would specify Macintosh folders instead of \Windows. ' Specifying 1 as the second argument opens the application in ' normal size and gives it the focus. Dim RetVal RetVal = Shell("C:\WINDOWS\CALC.EXE", 1) ' Run Calculator. windowstyle - Optional. Variant (Integer) corresponding to the style of the window in which the program is to be run. If windowstyle is omitted, the program is started minimized with focus. On the Macintosh (System 7.0 or later), windowstyle only determines whether or not the application gets the focus when it is run. "Geoff" wrote: 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 |
#15
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
I thought I had included this bit in the Shell Funtion blurb, but being late
at night over here, I guess I overlooked it. Instead of RetVal = Shell("hh.exe c:\xxx.chm", 1) Try RetVal = Shell("hh.exe c:\xxx.chm", 3) According to the help file, the three will return the window as maximized. "Geoff" wrote: Hi In post #6 of this thread you can find that snippet. What my code does in this case is open the help.chm file, note its id and check if it's still running should the cmdbutton be used again. My problem is in wanting to do something with that second press - I can either give a message or Restore the window assuming it has been minimised. So the snippet gets part way. Thanks for your endeavours so far, I appreciate the help in a difficult area. Geoff "JLGWhiz" wrote: Geoff, don't know if this will help, but I got it out of the VBA help files. Shell Function Example This example uses the Shell function to run an application specified by the user. On the MacIntosh, the default drive name is €œHD€ and portions of the pathname are separated by colons instead of backslashes. Similarly, you would specify Macintosh folders instead of \Windows. ' Specifying 1 as the second argument opens the application in ' normal size and gives it the focus. Dim RetVal RetVal = Shell("C:\WINDOWS\CALC.EXE", 1) ' Run Calculator. windowstyle - Optional. Variant (Integer) corresponding to the style of the window in which the program is to be run. If windowstyle is omitted, the program is started minimized with focus. On the Macintosh (System 7.0 or later), windowstyle only determines whether or not the application gets the focus when it is run. "Geoff" wrote: 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 |
#16
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
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 |
#17
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
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 |
#18
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
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 |
#19
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#20
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
The code, as is, raises the .chm but does not prevent multiple instances.
The example I posted aims to cater for just that - If the chm is open (ie its window handle is found) then restore the chm window to front Else Open the chm with Shell End if The restore with the API call as I posted is to the previous window 'restored' .coordinates or maximized as previously left by the user. If you want to reset to the coordinates you set in the html workshop you could do that with another API with hardcoded coordinates. Personally I wouldn't, if user subsequently resized or maximized it might have been for user's preference, and easy for user to resize if necessary. As I mentioned previously, the html help API gives a lot more control, but Shell works too Regards, Peter T "Geoff" wrote in message ... 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 |
#21
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taskbar and applications
Hi Peter
Thanks, that's put me on the right track. Just have to evaluate the default positioning etc now. Geoff "Peter T" wrote: The code, as is, raises the .chm but does not prevent multiple instances. The example I posted aims to cater for just that - If the chm is open (ie its window handle is found) then restore the chm window to front Else Open the chm with Shell End if The restore with the API call as I posted is to the previous window 'restored' .coordinates or maximized as previously left by the user. If you want to reset to the coordinates you set in the html workshop you could do that with another API with hardcoded coordinates. Personally I wouldn't, if user subsequently resized or maximized it might have been for user's preference, and easy for user to resize if necessary. As I mentioned previously, the html help API gives a lot more control, but Shell works too Regards, Peter T "Geoff" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Taskbar | Excel Discussion (Misc queries) | |||
sql vba applications | Excel Programming | |||
taskbar | Excel Discussion (Misc queries) | |||
Using VBA to select applications... | Excel Programming | |||
Other applications | Excel Programming |