DebsPink

I am beginning to migrate a simple VBA toolbar to Office 2007 using VSTO. I have managed to recreate some of the buttons on a new Ribbon tab, but I just can't find out how to link one the buttons to launch a Help file. I have converted my old .HLP file to HTML (.CHM) but can't find any easy to understand instructions or advice on how to link the "isPressed" bit in the Ribbon.vb class to launch the .chm file. I think it's something to do with Help.ShowHelp, but I'm struggling with the syntax. Also does the .chm file need to be attached as a resource Many thanks.

Re: Visual Studio Tools for Office Launching a Help File (.CHM) from a VSTO addin

Dennis Wallentin

Hi,

To launch chm file from VSTO can be done in the following way:

1. Insert at the top of the module the following statement (VB syntax): Imports System.Reflection

2. Add the following to a procedure: Process.Start(Path & "\NameOfTheFile.chm")

3. Where Path is a string variable that holds the pathway to the VSTO solution, i e for a workbook solution it would be like:

Dim Path as String = Globals.ThisWorkbook.Path






Re: Visual Studio Tools for Office Launching a Help File (.CHM) from a VSTO addin

DebsPink

Thanks the the advice. It worked! However I had to put the full path in. I guess that's because I have an Word Addin, so I got Globals.ThisAddin, but there was no Path option. Should I be including the .chm file as a resource or just deploying the file as a normal help file and pointing the addin to it Thanks for your help.



Re: Visual Studio Tools for Office Launching a Help File (.CHM) from a VSTO addin

Dennis Wallentin

Hi,

OK, so it's an add-in You're working with.

I'm not a friend of hard cording path so the best approach will be the following:

[code]

Imports System.Reflection

Dim AddInLocation As String = Assembly.GetExecutingAssembly().CodeBase.ToString

View_Help(AddInLocation)

[/code]

[code]

Friend Sub View_Help(ByVal asmLocation As String)

'Cleaning up the CodeBase string in order to use it.

Dim location As String = Right$(asmLocation, Len(asmLocation) - 8)

location = Left$(location, Len(location) - 12)

location = Replace(location, "/", "\")

'Open the help file.

Process.Start(location & "\DataTool.chm")

End Sub

[/code]

I would suggest that You add the helpfile to the project, at least to the setup project.






Re: Visual Studio Tools for Office Launching a Help File (.CHM) from a VSTO addin

DebsPink

Hi, yes that worked thank you. Although I'm still not 100% sure of how it worked, but I'm sure it will sort itself out and I can now move onto other problems!

Thanks again.