none
Installation path from an Office Add-In read with VB RRS feed

  • Question

  • Hello,

     

    I need the installation path chosen in the setup routine from my Add-In read with VB in "ThisAddIn.vb"

     

    Thank you!

       Michael

    Wednesday, August 3, 2011 9:46 AM

Answers

  • Hi Michael,

    If you're using Visual Studio and creating an add-in for MS Project I assume it would load into either the Local Machine Hive or Current User Hive and if that is true here is an example of finding the path string to where the add-in manifest resides.

        Dim myKey As String = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\MS Project\Addins\MyAddinName"
        Dim myLoc As String = My.Computer.Registry.GetValue(myKey, "Manifest", Nothing)
    
    


     If you're looking for where your setup was directed to load other files, I would add a custom registry entry in the Local Machine Hive\Software\Your Company\Your Product\Path


    Kind Regards, Rich ... http://greatcirclelearning.com
    • Marked as answer by Michael-Markus Thursday, August 4, 2011 11:22 PM
    Thursday, August 4, 2011 9:36 PM

All replies

  • Hello Michael,

     

    Have you tried just checking the startup path of the addin?

    You can do this by using the following code.

     

    Dim installPath As String = Application.StartupPath
    

    This should be the path from which the addin was installed and is now running.

    If this will not surfice, you can also check the Addin installation path from the registry.

    For example:

    An Excel addin HKCU\Software\Microsoft\Office\Excel\Addins\YourUniqueNameForYourAddinHere: Under this key a string value called "Manifest" Should hold the path to your addins manifest location. For example: "C:\Program Files\Your Company Name\AddinName\AddinName.vsto"

    Hope this helps,

    Ed


    Wednesday, August 3, 2011 10:18 AM
  • Hello,

     

    thank you  ...

    > Dim installPath As String = Application.StartupPath
    ... but this code works with Excel and not with MS-Project.

    I don't know, why this not work with MS-Project.

    Have you a VB code example for MS-Project too?

    Regards

      Michael 

     

     

    Wednesday, August 3, 2011 11:30 AM
  • Michael,

    Sorry about that I didn't know you were working with MS Project.

    Have you tried this: Dim installPath As String = My.Application.Info.DirectoryPath

    I can't test this at the moment as I don't have Project on this workstation.

    Let me know if this helps.

    Ed

    Wednesday, August 3, 2011 12:04 PM
  • Hello,

     

    > Dim installPath As String = My.Application.Info.DirectoryPath

    > Let me know if this helps.

     

    I'm afraid not!

    The code "Msgbox(installPath)" shows "C:\User\Admin\AppData\Local\assembly\dl3\C5A3 ....."

    My Add-In is installed at "C:\program files\company\pm assistant\"

     

    Have you now another idea?

    Michael

     

     

    Wednesday, August 3, 2011 12:41 PM
  • Hello,

    I normally work within c# and found this article a while back when I was doing something simular to what your asking. I don't have time at the moment to convert it to VB.net for you but you might give this a try. It users the MSI.dll (WindowsInstaller.Installer) to loop through all the installed msi products and find the one your looking for by name and then gets the install location. You will have to add a reference to your project for the Microsoft Windows Installer from the COM objects selection to your project.

    The link is here.

    http://stackoverflow.com/questions/1309142/determine-3rd-party-application-installation-directory

    If you have problems converting I will see if I can get to it this afternoon.

    Ed

    Wednesday, August 3, 2011 1:59 PM
  • Hello,

     

    > If you have problems converting I will see if I can get to it this afternoon.

     

    Thank you, because I can not C#

     

    Regards

       Michael

     

    Wednesday, August 3, 2011 9:36 PM
  • Michael,

    Sorry for the delay. I decide to go with something a little more simple so I could get you going again. The below code loops through the registry of installed products and retrieves their name and install location. When you run it many will have a blank value for the install location hopefully your addin installer will populate this field, on my test it did.

    Here you go.

    Sub Main()
            Dim ProductName As String
            Dim InstallLocation As String
            Dim SoftwareKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products"
            Dim regKey As RegistryKey = Registry.LocalMachine.OpenSubKey(SoftwareKey)
            Dim uid() As String = regKey.GetSubKeyNames()
            For Each installKey In uid
                Try
                    ProductName = regKey.OpenSubKey(installKey).OpenSubKey("InstallProperties").GetValue("DisplayName").ToString()
                    InstallLocation = regKey.OpenSubKey(installKey).OpenSubKey("InstallProperties").GetValue("InstallLocation").ToString()
                    If ProductName = "YourAddinSetupNameHere" Then
                        Console.WriteLine("Install Location is: " + InstallLocation)
                    End If

                Catch
                    Console.WriteLine("One of the keys doesn't exist")
                End Try

            Next

        End Sub

    Good luck


    Thursday, August 4, 2011 6:37 PM
  • Hi Michael,

    If you're using Visual Studio and creating an add-in for MS Project I assume it would load into either the Local Machine Hive or Current User Hive and if that is true here is an example of finding the path string to where the add-in manifest resides.

        Dim myKey As String = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\MS Project\Addins\MyAddinName"
        Dim myLoc As String = My.Computer.Registry.GetValue(myKey, "Manifest", Nothing)
    
    


     If you're looking for where your setup was directed to load other files, I would add a custom registry entry in the Local Machine Hive\Software\Your Company\Your Product\Path


    Kind Regards, Rich ... http://greatcirclelearning.com
    • Marked as answer by Michael-Markus Thursday, August 4, 2011 11:22 PM
    Thursday, August 4, 2011 9:36 PM
  • Hi Rich,

    Many, many thank's for you.

    It works perfect!

    Regards

       Michael

    Thursday, August 4, 2011 11:22 PM