Adding and launching a help file.

Add-in Express™ Support Service
That's what is more important than anything else

Adding and launching a help file.
 
learningaddinexpress




Posts: 16
Joined: 2020-03-19
I am currently using the below code to launch the help file


    Private Sub Help_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles Help.OnClick
        Dim path = System.IO.Path.Combine(Application.StartupPath, "Help.chm")
        Dim psi As New ProcessStartInfo(path) With {.Verb = "open"}
        Dim p As New Process With {.StartInfo = psi}
        p.Start()
    End Sub


This relies on specifying the physical path of the file. So I have two quesiotns.

1. How do I embed the file in my Add-In and create the setup?
2. How do I launch the help file?

Thanks for the continued support.
Posted 20 Mar, 2020 04:19:33 Top
Andrei Smolin


Add-in Express team


Posts: 17178
Joined: 2006-05-11
Hello Mike,

Include the file(s) to the setup project. In the code of the add-in use this construct (C#) to get that file on the target machine:

string location = Assembly.GetExecutingAssembly().CodeBase;
string fullPath = new Uri(location).LocalPath; // path including the dll
string directoryPath = Path.GetDirectoryName(fullPath); // directory path


Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Mar, 2020 04:54:48 Top
learningaddinexpress




Posts: 16
Joined: 2020-03-19
Thanks Andrei

1. How do you add the file? Right Click on "Application Setup | Add | File" in solution explorer?
2. The code that you gave, where does it go? Sorry I am slightly confused?

Did you mean


    Private Sub Help_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles Help.OnClick
        Dim location As String = Assembly.GetExecutingAssembly.CodeBase
        Dim fullPath As String = (New Uri(location) + LocalPath)
        Dim directoryPath As String = Path.GetDirectoryName(fullPath)

        Dim psi As New ProcessStartInfo(directoryPath) With {.Verb = "open"}
        Dim p As New Process With {.StartInfo = psi}
        p.Start()
    End Sub


If yes then what is "LocalPath"?
Posted 20 Mar, 2020 05:25:48 Top
Andrei Smolin


Add-in Express team


Posts: 17178
Joined: 2006-05-11
Hello Mike,

#1. What deployment software did you you use to create your setup project? Do you have a setup project at all?
#2. In your Help_OnClick method, replace Application.StartupPath with the directoryPath from my code fragment.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Mar, 2020 05:32:40 Top
learningaddinexpress




Posts: 16
Joined: 2020-03-19
#1 Application | Add-In Express | Create Setup Project | Visual Studio Installer

#2 I assumed that and hence I had already modified my previous post. That brings to the same quesiotn. What is "LocalPath"

Thanks again.
Posted 20 Mar, 2020 05:36:31 Top
learningaddinexpress




Posts: 16
Joined: 2020-03-19
#2

Or did you mean this?


    Private Sub Help_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles Help.OnClick
        Dim location As String = Assembly.GetExecutingAssembly.CodeBase
        Dim fullPath As String = (New Uri(location) + LocalPath)
        Dim directoryPath As String = Path.GetDirectoryName(fullPath)

        Dim finalpath = System.IO.Path.Combine(directoryPath, "Help.chm")
        Dim psi As New ProcessStartInfo(finalpath) With {.Verb = "open"}
        Dim p As New Process With {.StartInfo = psi}
        p.Start()
    End Sub
Posted 20 Mar, 2020 05:39:58 Top
Andrei Smolin


Add-in Express team


Posts: 17178
Joined: 2006-05-11
learningaddinexpress writes:
(New Uri(location) + LocalPath)


"New Uri(location).LocalPath", not "New Uri(location) + LocalPath"

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Mar, 2020 05:43:33 Top
learningaddinexpress




Posts: 16
Joined: 2020-03-19
"New Uri(location).LocalPath", not "New Uri(location) + LocalPath"


May I safely blame the code convertor for that :P

Sorry my bad. I should have read what the code is doing...

That leaves us with #1. If you could please help me with that as well?
Posted 20 Mar, 2020 05:48:49 Top
Andrei Smolin


Add-in Express team


Posts: 17178
Joined: 2006-05-11
No problem.

#2.
- right-click your setup project | Vie | File System
- double-click the Application folder
- right-click the area below the list of files in the Application folder | Add | File; specify the file to add and click OK

That's all.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Mar, 2020 05:55:39 Top
learningaddinexpress




Posts: 16
Joined: 2020-03-19
Oh Yea I was looking for this section. I thought it was not there...

Thanks a ton. This sorted eveything!
Posted 20 Mar, 2020 06:04:17 Top