Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2006

Tip: Looking for answers? Try searching our database.

Get default add-in path

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RB Smissaert - 30 Sep 2006 10:21 GMT
What is the best way to get the default .xla add-in path?

Will this always be Application.UserLibraryPath ?

Or should I use a function like this:

Function GetDefaultAddinPath(Optional strIdentifier _
                            As String = "\addins\") As String

  Dim i As Long
  Dim lCount As Long
  Dim lPos As Long

  strIdentifier = UCase(strIdentifier)
  lCount = Application.AddIns.Count

  For i = 1 To lCount
     lPos = InStr(1, UCase(Application.AddIns(i).FullName), _
                  strIdentifier, _
                  vbBinaryCompare)
     If lPos > 0 Then
        GetDefaultAddinPath = Left$(Application.AddIns(i).FullName, _
                                    lPos + Len(strIdentifier) - 1)
        Exit Function
     End If
  Next i

End Function

RBS
Peter T - 30 Sep 2006 12:30 GMT
Hi Bart,

That function appears to return the path of the first addin in the
collection that happens to exist in a folder named somepath\addins. That
assumes there is at least one addin that has a path (ie not one of the
bundled addins) and user hasn't put it in a user named folder of same name
"addins". So I would have thought the simple return you mentioned, or to
cater also for XL97 -

Function GetDefaultAddinPath2() As String
Dim sPath As String, sSep As String
   #If VBA6 Then
       sPath = Application.UserLibraryPath
   #Else
       sPath = Application.LibraryPath
   #End If
   sSep = Application.PathSeparator
   If Right$(sPath, 1) <> sSep Then
       sPath = sPath & sSep
   End If
   GetDefaultAddinPath2 = sPath
End Function

Regards,
Peter T

> What is the best way to get the default .xla add-in path?
>
[quoted text clipped - 26 lines]
>
> RBS
RB Smissaert - 30 Sep 2006 12:58 GMT
Hi Peter,

I just wondered if Application.UserLibraryPath would be foolproof or if I
needed something
along the lines (but as you say would need to be worked out a bit further)
of the function that
loops through all the add-in path's.

I have now gone with the simple Application.UserLibraryPath.
Thanks for the refinement for XL97 although I don't think I have users on
that anymore.

I needed to know this as despite having an installer that to me seems to
cover all some users still
manage to install to the default add-in folder and that causes all sorts of
problems for my app.
So I check for this and delete (kill) some files if they are there.

Bart

> Hi Bart,
>
[quoted text clipped - 52 lines]
>>
>> RBS
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.