Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default programmatically close help file before Excel closes?

Using Excel XP.
I am having the following problem.

Have a userform that can launch a .chm help file with the following code:

'this API function is for displaying the help file
Private Declare Function HtmlHelpTopic Lib "hhctrl.ocx" _
Alias "HtmlHelpA" _
(ByVal hWnd As Long, _
ByVal lpHelpFile As String, _
ByVal wCommand As Long, _
ByVal dwData As String) As Long


Sub ShowHtmlHelp(ByVal strHelpFile As String, _
Optional ByVal strHelpPage As String)

Const HH_DISPLAY_TOPIC As Long = &H0

On Error Resume Next
HtmlHelpTopic 0&, strHelpFile, HH_DISPLAY_TOPIC, strHelpPage

End Sub


Sub ShowHelp()

Dim AddinFolder As String

AddinFolder = _
Left(ThisWorkbook.FullName, Len(ThisWorkbook.FullName) - 21)

ShowHtmlHelp AddinFolder & "\Test.chm"

End Sub


This works all fine.

The problem is when the help file is loaded, the userform gets closed and
then Excel gets closed.
Excel then crashes.
So I have to make sure that the help file gets closed before Excel closes.
Perhaps I need an API function here, but I can't figure it out.
Thanks for any advice.


RBS



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default programmatically close help file before Excel closes?

Hi RB,

The return value from the call to HtmlHelp is the hWnd of the help window,
which you should store in a module-level variable, then use the SendMessage
API function to send it a WM_CLOSE message to close it.

Regards

Stephen Bullen

Using Excel XP.
I am having the following problem.

Have a userform that can launch a .chm help file with the following code:

'this API function is for displaying the help file
Private Declare Function HtmlHelpTopic Lib "hhctrl.ocx" _
Alias "HtmlHelpA" _
(ByVal hWnd As Long, _
ByVal lpHelpFile As String, _
ByVal wCommand As Long, _
ByVal dwData As String) As Long

Sub ShowHtmlHelp(ByVal strHelpFile As String, _
Optional ByVal strHelpPage As String)

Const HH_DISPLAY_TOPIC As Long = &H0

On Error Resume Next
HtmlHelpTopic 0&, strHelpFile, HH_DISPLAY_TOPIC, strHelpPage

End Sub


This works all fine.

The problem is when the help file is loaded, the userform gets closed and
then Excel gets closed.
Excel then crashes.
So I have to make sure that the help file gets closed before Excel closes.
Perhaps I need an API function here, but I can't figure it out.
Thanks for any advice.



Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default programmatically close help file before Excel closes?

Stephen,

Thanks for that. Got it sorted now.

RBS


"Stephen Bullen" wrote in message
...
Hi RB,

The return value from the call to HtmlHelp is the hWnd of the help window,
which you should store in a module-level variable, then use the

SendMessage
API function to send it a WM_CLOSE message to close it.

Regards

Stephen Bullen

Using Excel XP.
I am having the following problem.

Have a userform that can launch a .chm help file with the following

code:

'this API function is for displaying the help file
Private Declare Function HtmlHelpTopic Lib "hhctrl.ocx" _
Alias "HtmlHelpA" _
(ByVal hWnd As Long, _
ByVal lpHelpFile As String, _
ByVal wCommand As Long, _
ByVal dwData As String) As Long

Sub ShowHtmlHelp(ByVal strHelpFile As String, _
Optional ByVal strHelpPage As String)

Const HH_DISPLAY_TOPIC As Long = &H0

On Error Resume Next
HtmlHelpTopic 0&, strHelpFile, HH_DISPLAY_TOPIC, strHelpPage

End Sub


This works all fine.

The problem is when the help file is loaded, the userform gets closed

and
then Excel gets closed.
Excel then crashes.
So I have to make sure that the help file gets closed before Excel

closes.
Perhaps I need an API function here, but I can't figure it out.
Thanks for any advice.



Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk


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
why do all excel files close when one closes? janet inglis Excel Discussion (Misc queries) 7 February 5th 09 12:38 PM
why do all excel files close when one closes? FSt1 Excel Discussion (Misc queries) 0 February 4th 09 08:08 PM
when i insert word art in excel sheet excel file closes automatica marwin Excel Discussion (Misc queries) 1 April 10th 06 03:29 PM
Excel closes all open apps when i close one ipctech Excel Discussion (Misc queries) 1 May 25th 05 12:04 AM
Excel 2003 File Closes In 2000 [email protected] Links and Linking in Excel 0 March 5th 05 05:20 PM


All times are GMT +1. The time now is 01:11 PM.

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

About Us

"It's about Microsoft Excel"